Script for renaming files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for renaming files
# 1  
Old 10-13-2010
Script for renaming files

I wanna back up the original version of files in a directory by appending .ORIG to them. I'm guessing I'd need CP and AWK in some form or fashion. Can someone give me a template? Thanks
# 2  
Old 10-13-2010
Code:
find /path/to/directory -maxdepth 1 -type f -exec echo cp -a  {} {}.ORIG \;

Did you ever consider snapshots or snapshot-like using rsync ?
# 3  
Old 10-13-2010
Nah didn't know about it, I'll give it a peep
# 4  
Old 10-14-2010
Code:
for F in *; do cp "$F" "${F}.ORIG"; done

To exlude already backuped files:
Code:
for F in *; do [ "${F##*.}" != "ORIG" ] && cp "$F" "${F}.ORIG"; done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

2. Shell Programming and Scripting

bulk renaming of files in sftp using script

Hi, Am using sftp (dsa method) to transfer 20 files from one server(sftp) to another (local). After the transfer is complete the files in the sftp server has to be renamed from .txt extension to .done extension ( aa.txt to aa.done, bb.txt to bb.done and likewise...). I tried rename command... (4 Replies)
Discussion started by: Sindhuap
4 Replies

3. Shell Programming and Scripting

Need script for renaming and moving files one by one...

Dears, I need your help! I got a problem and found some workaround solution but I donno how to realize it. I have a number of files (about 300 each day) and I need them to be renamed. All these files has fixed number of letters and name looks like this one:... (7 Replies)
Discussion started by: nypreH
7 Replies

4. Shell Programming and Scripting

Renaming multiple files with a shell script

Hey guys, I'm really new to UNIX and shell scripting in general. For my internship I need to rename a bunch of files. Specifically, I need to change the first letter of each of the files to lowercase and I have to change the endings so they all basically look like "file_cone.jpg". I know I... (4 Replies)
Discussion started by: jjzieve
4 Replies

5. Shell Programming and Scripting

perl thread script for renaming files

i need a threaded perl script, each thread browsing the same directory but renaming different files. Thread A renames file “aaa” to “xxx”, Thread B renames file “bbb” to “yyy” Thread C renames file "ccc" to "zzz" ..... etc (2 Replies)
Discussion started by: anand121
2 Replies

6. Shell Programming and Scripting

script for renaming a batch of files

hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Discussion started by: shabs1985
3 Replies

7. Shell Programming and Scripting

Need help with shell script for moving/deleting/renaming files

Hi. I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next. Here's an example: /var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Discussion started by: aflower
4 Replies

8. UNIX for Dummies Questions & Answers

Renaming Files using Shell Script

Hi Gurus, I have some files(all ending with .out as extension). Ex: aa1.out aa2.out aa3.out I would like to append each file with the current date to the end of the file so that they should become aa1_20090504.out. So I am using rename as follows: for i in path/aa* ; do mv $i... (5 Replies)
Discussion started by: asmfloyd
5 Replies

9. Shell Programming and Scripting

copying files and Renaming them + shell script

Hi, I have a problem. I have some text files in a folder. The names can be like: emp.txt emp1.txt emp3.txt 32emp4.txt What i need is i have to copy all the files which have "emp" string in their filename to a different folder and those file names... (7 Replies)
Discussion started by: pathanjalireddy
7 Replies

10. Shell Programming and Scripting

Renaming files in a bash script

I'm doing a short batch script to compile po files producing output binary mo files. The compilation command is: msgfmt -o file.mo file.po so in order to compile I am appending .mo to the varible in a loop. It goes something like this: for i in `find . -name "*.po"` do echo... (2 Replies)
Discussion started by: Breen
2 Replies
Login or Register to Ask a Question