I have a folder full of images with several different random file names to help organize this mess I would like to, in one command rename all of them to a sequential order so if I have 100 files it starts off naming the first file file-1.jpg
file-2.jpg
etc. Is this possible in one command?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
- Null-terminated string, opening file for reading
The most concise command line to do this I can think of is
ls
lists the files in the current directory andcat -n
adds line numbers. Thewhile
loop reads the resulting numbered list of files line by line, stores the line number in the variablen
and the filename in the variablef
and performs the rename.I was able to solve my problem by writing a bash script