File count with script?
I am trying to write a small script that will rename my digital camera photo's the have weird names like DCD 20040925 to a simpler naming of just a 4 digit numbering system ie. 0001, 0002, 0003.jpg, etc. I was suggested to me that I do a file count of the folder that the pics are in, then have the names changed to progress up to the file count? Wel I am having trouble finding how to obtain a file count, and curious if there may be a better way to do this? Thanks a bunch.
-Kevin |
One possible way is to run the following command:
Code:
ls -1 | wc -l That will count how many things are in a directory. "Things" includes regular files and directories. If there are directories mixed with the images, I would suggest reading up on the find command (man find) with specific attention to the "-type" and "-maxdepth" options. |
Quote:
Code:
ls |
Here is something which may get you started. You should try it on a practice folder first.
Code:
#!/bin/bash |
Homey.....
Thank you for the help, with a few minor alterations to the script I was able to use alot of what you gave me and it works perfect. |
All times are GMT -5. The time now is 06:19 PM. |