If I have a list of file names in an XML and want to remove all instances where the file name doesn't have a file extension, how can I do this using regular expressions? I need to do the replace in TextWrangler and have no other option unfortunately.
For example, if I have such a list in an XML as:
<name>AAA_A026C032_150522_R4RO.mov</name>
<name>BBB_A016D032_150809_R4RO.aiff</name>
<name>CCC_A026C038_151010_R4RO</name>
<name>DDGS_A006C132_150409_R4RO.mp3</name>
<name>EFFD_B026C001_150607_R4RO</name>
<name>FGHG_A026C032_141215_R4RO.cine</name>
Have can the files without the file extension be targeted using regular expressions? I would like to replace these (clear them) in the output document.
Thanks in advance,
Matt
'(?!>\w+\.[a-zA-Z0-9]+)>(\w+)'
this pattern gets the name of the files without extensions as its first capturing group. I dont know how to use TextWrangler but I assume that with filename string, you can probably figure it out?
Related
I need a way, in a Mirth file reader channel, to pick up all files but one with a given name. I can use a regex expression in the Filename Filter Pattern box.
Most files are of the format #######.brf. I need to pick up any file that isn't named 0050450.brf. Can someone help with this?
Thanks
Rut
I think this one should work: ^(?!(0050450\.brf))\w*\.brf
I'm using Atom. I've pressed the ".*" button to turn on regular expressions. I'm trying to search for a string only in a file with a path that contains the "src" directory somewhere in the path. I would expect .*\/src\/.* to work but it doesn't. I've tried a bunch of permutations of this but still no luck.
What am I doing wrong?
Sample path "/Users/me/Development/ui/ui-enduser/src/main/js/config/AppConfiguration.js"
For the benefit of those with a similar issue, according to this link Atom uses minmatch library.
The syntax for this would be something like:
/Users/me/Development/\*\*/src/\*\*/
assuming you wanted to limit your search to subdirectories of /Users/me/Development/.
If you also wanted to limit your search to certain extension the syntax would be:
/Users/me/Development/\*\*/src/\*\*/\*.ext
/ is a special character in regular expressions. Try escaping them: \/src\/, or if you want the whole string, ^.*\/src\/.*
I use free little program Metamorphose for changing file names.
Problem is I need to use regex to change names in order as shown below:
Find: nice-tree-([\s\S]*?)
Replace: nice-tree-$1-abc
As you can see all files that start with nice-tree-ANYTHING should be replaced with -abc at the end of every file name.
I'm everything just not expert for regex usage...
Both of you were right. It works now. Thanks.
Assuming you don't need to replace the full file name with the extension. The following regex would match all the file names that you are looking for.
/nice-tree-.+/
I am trying to find a way to list all file names in a folder that matches this pattern :
20131106XXXXX.pdf
The prefix is the date, and the content and length of XXXX vary across files, and I only care about pdf files.
Anyone could advise a way to do this?
Try this
list.files(path="./yourdir",pattern="[[:digit:]]{8}.*\\.pdf")
You can use regex.
files <- dir(pattern="^[0-9]{8}.*\\.pdf")
I 'm not a coder/programmer so my knowledge about regex is limited on what I can find on Google and sites like stackoverflow.
I have a series of files, around 10k with different filenames. Now I want to put the specific filename of each file into a line within the txt file, preferably on the first or last line of the file.
So if I have a file with the filename Caste "System in Nepal.txt" I want to see "Caste System in Nepal" on either the first or second line of the txt, without the quotes.
Can anybody help me? Thanks a lot. :)
Have a go with the following:
(.+?)\.\w+
The bit in the brackets you'd then use for your file name. This assumes that there is only one dot in the filename before the extension. Otherwise, if you have filenames like Document.name.txt, you'll need a more complex regex.
I'm not sure you can do this from within Notepad++ as you'll need the list of files to begin with. If you already have this then you can use find and replace to find .txt (if they all have the .txt extension) and replace it with nothing. If you have other extensions then try a regexp like \.[^\.]$ and replace it with nothing. That should match the last fullstop and everything after it.
If you don't have the list of files in your text editor then you can get them from a Bourne compatible shell with something like find . -type f -print > ../file-you-want-the-list-in.txt run in the directory with all the files in.