Note that if the starting number read into n is not 1, there is a chance that one or more of the original files will be copied into multiple renamed files and each time one of the original files is duplicated another original file will be destroyed. For instance, if the directory originally contained:
and you entered 3 as the starting value, this script would end up with the files:
all of which contained what was originally stored in the file named DSC_0002.JPG and the images that had been stored in DSC_0003.JPG and DSC_0004.JPG are lost (unless you made a backup copy of your files before running this script).
Note that if the starting number is 1 or if the starting number is greater than the highest number used in any existing file added to the number of files matching the pattern *.JPG when the script starts, you will be safe as long as all of the input files in the directory that match the pattern *.JPG also match the pattern DSC_[0-9][0-9][0-9][0-9].JPG.
Note that if the starting number read into n is not 1, there is a chance that one or more of the original files will be copied into multiple renamed files and each time one of the original files is duplicated another original file will be destroyed. For instance, if the directory originally contained:
and you entered 3 as the starting value, this script would end up with the files:
all of which contained what was originally stored in the file named DSC_0002.JPG and the images that had been stored in DSC_0003.JPG and DSC_0004.JPG are lost (unless you made a backup copy of your files before running this script).
Note that if the starting number is 1 or if the starting number is greater than the highest number used in any existing file added to the number of files matching the pattern *.JPG when the script starts, you will be safe as long as all of the input files in the directory that match the pattern *.JPG also match the pattern DSC_[0-9][0-9][0-9][0-9].JPG.
You're right. I lose the files. How can I fix?
Thank you
You're right. I lose the files. How can I fix?
Thank you
Unless you had backups of your files before you destroyed some of them, they are gone. To avoid the problem in the future, change the script suggested by rdrtx1 to something more like:
This User Gave Thanks to Don Cragun For This Post:
Hi all,
I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to
find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
hi there,
i'm using OS X.
i have a bunch of mp3 files strewn across a directory tree that i'd like to rename.
specifically i'd like to remove any track numbers and leading non-alphabetic characters from the filenames like this:
01 - song1.mp3
2 song2.mp3
become:
song1.mp3... (6 Replies)
Hi All,
I want to write a script to rename the file in to the incremental order
for example
Original file
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
filename=/nfs/n1/file1.img
I want output shpuld be... (4 Replies)
I have the following directories in my home directory,
my scripts
dbmig es
ms_done
my-home
I want my output to look like the following
MyScripts
DbmigEs
MsDone
MyHome
Basically, I want to get rid of spaces,special characters and convert the first letter of each word to uppercase and... (1 Reply)
Hello,
I have this problem.
In a directory I have 4 csv files with this format:
PHOENIX_KM_INTERAZIONI_YYYYMMDD.csv
PHOENIX_KM_TRIPLETTE_YYYYMMDD.csv
NEWCAB_KM_INTERAZIONI_YYYYMMDD.csv
NEWCAB_KM_INTERAZIONI_YYYY_MM_DD.csv
YYYYMMDD: format CURRENT date
I wont rename all files in... (4 Replies)
I wrote a simple script that converts my windows text files to unix, so that I can compare them to different unix files purposes of my project.
win2unix file1.txt file1Win.txt
win2unix file2.txt file2Win.txt
etc
Is there a way to simplify this to:
<while .txt in... (5 Replies)
Hi, i need a bit of help writting a tcsh script which renames all ascii text files in the current directory by adding a number to their names before the extension
so for example, a directory containing the files
Hello.txt
Hello.t
Hello
should have the following changes,
Hello.txt... (2 Replies)
Let me preface this by stating I have absolutely no idea what I'm doing in this arena, but I'm in need of a little help here.
I need to take filenames like this: amwed_0402c-slug~1-cp.jpg
And reduce them to slug~1.jpg
That is, I need to remove the first 12 and last 3 characters. The... (3 Replies)
Have files of the sort 3p1522015.dgn and need to have them renamed to 152201.dgn. Essentially dropping the 1st 2 characters and the last. I'm relatively new to UNIX and uncertain of where to start. I hope this provides enough detail.
Thanks (5 Replies)
Hi All !!!
Is there any solution to get rid of / " * in old files names WITH A SCRIPT
(About 100 Gb of old files)
I know it can be done i just dont know how !
Hope that some one can help
Best R.
Yovel (1 Reply)