Rename multiple files, changing prefix, extension and dropping characters
I'm currently only able to perform some very basic functions, so hope this makes sense...
I have a set of about 27 files that need to be renamed from something like this:
to something like this:
The file names currently all start with '0000', then a 2-digit value, then a name that can be anywhere from 2 to 10 characthers, then the same extension. They need to be changed to a new prefix + 0 + the existing 2 digit value, dropping the next 2 to 10 characters, and changing the extension on each file to the new one. All are case sensitive as indicated.
I was able to use one-liners to get to a file name like 'newa012PQ.abc', and am having the most trouble trying to understand how to drop the 'PQ' etc.
As I said I'm not familiar with much of this and see a lot of references to sed and awk etc. but short of copying code I'm not sure the meaning of, or messing with scripting that I've never touched before I figured I'd try here first.
Any help is appreciated!
Thanks
Last edited by Scrutinizer; 05-15-2012 at 04:08 PM..
Reason: code tags
I have a good script to rename multiple files, but what's the best way I can remove some text from multiple filenames? Say I have a directory with 35 files with a .XLS at the end, how can I rename them to remove the .XLS but keep everything the same, without having to mv manually. Thanks. (6 Replies)
Hello
i have the files in this format
pdb1i0t.ent
pdb1lv7.ent
pdb1pp6.ent
pdb1tj2.ent
pdb1xg2.ent
pdb2b4b.ent
pdb2ewe.ent
Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt
The new file should look like this
... (3 Replies)
I've been trying to find information in regard to creating a script that will generate HTML files. I currently have a series of files that contain code I need to surround with a <textarea> tag for easy viewing. I have about a thousand files that contain code, one file that contains the HTML code up... (10 Replies)
Hello guys,
I was looking for a shell script that removes all the special characters from the files and the subdirectories recursively. I could not locate it any more. Dose any body have a similar script that dose that?
Thanks for the help.
AV (0 Replies)
hi!
i want to rename all files with no extension with the extension DAT.
with this command ls |grep -v "\\." i can list files but i dont know how i am going to rename them..
so
i tried
FILE_LIST=ls |grep -v "\\."
for TEST_FILE in ${FILE_LIST}
do
mv $TEST_FILE... (2 Replies)
Hi,
I have files with filenames as below.
SGM Daily Sales Email-en-us-05312012.xlwa
I want to rename it in .xls. I am writing a script to change this, as there can be multiple files in subfolders.
I have the following script.
#!/bin/ksh
for oldfile in $(find... (1 Reply)
currently in my directories
$ ls -lrth
total 32K
-rw-r--r-- 1 oracle oinstall 864 Feb 25 16:01 cor_bin_gateway_cnt.sql
-rw-r--r-- 1 oracle oinstall 782 Feb 25 16:01 mer_bin_gateway_cnt.sql
I want to rename files with *.sql to *.mv extension, but when I execute the following
$ mv... (1 Reply)
Hi,
I want to rename several files like this:
example:
A0805120817.BHN
A0805120818.BHN
.....
to:
20120817.0805.N
20120818.0805.N
......
How can i do this via terminal or in shell bash script ?
thanks, (6 Replies)
Hi
I have a list a filename in a directory starting with particular pattern
for example:
abc_1234.txt
abc_7565.txt
abc_7676.txt
abc_7765.txt
i need to rename all these files by appending bck. or bck_
Expected output:
bck.abc_1234.txt
bck.abc_7565.txt
bck.abc_7676.txt... (1 Reply)
I am using the below curl command to download a single file from client server and it is working as expected
curl --ftp-ssl -k -u ${USER}:${PASSWD} ftp://${HOST}:${PORT}/path/to/${FILE} --output ${DEST}/${FILE}
let say the client has 3 files hellofile.101, hellofile.102, hellofile.103 and I... (3 Replies)