Find and Rename files made by Windoze users
I have a windows user that creates csv files and ftp to a linux server but they never follow any case structure so the file maybe
ABC.csv or Abc.CSV or Abc.CSV etc..
I need to find and rename it to just abc.csv
Please clarify, is your question on how to find the file, or how to rename the file?
You could use the 'find' (man find) command to find the files. The '-name' parameter can accept wild-cards (eg. '*.[Cc][Ss][Vv]')
and you can use the 'tr' (man tr) command to change the name to lower case (tr [:upper:] [:lower:]).
put these two into a loop or something and you will have a script that renames the file.
so find -iname file.csv and finds the file FILE.CSV than takes what if fines and runs the found file in a tr command something like
tr -s '[a-z][A-Z]' '[A-Z][a-z]' <FILE.CSV> file.csv
The problem is I not sure how to wrap this into one magic script :)
I think all I need to do is FIND the file and use a move command after it is found!
:) what do you think?
yes, if you can find the file you can change its name accordingly.
use "-atime n" switch command of "find" to access newly created file regardless of filename.
use the manual for command "find" to get acquainted to it.
user@host--$: man find
hope this helps.
you sure you don't want to try for yourself first? ...
** !!WARNING!! ** spoiler ahead. stop here if you'd rather research it yourself ...
|All times are GMT -5. The time now is 08:44 PM.|