I need an ftp script to do the following ;
mget *.DAT
mmove OR mrename *.dat *.old
I need the script to rename or move the files once they have been ftp'd. The reason is so that if the job runs again,it does not get the same files.
Any ideas ?
rather than the rm *.dat, you could use rename <origname.dat> <newname.whatever>
But if there are a lot of files you need to rename, I think you might need to do something with rexec, or schedule a cron job that can do the "mass" renaming after you get the dat files.
Can you not use the sunique command so that if a file being put has the same name, say "newfile", the next time another file named "newfile" is put, it will be called "newfile1".
Sorry but you are missing 1 point.
I do not know the file names , they vary every day.
I would like to rename them but cannot do "rename *.dat *.old". That is what I am trying to achieve.
Here is a script I use to rename file extensions, but I don't know how you can run it from the ftp session. As I said in my previous post, you may have to schedule it through cron. Perhaps when you do your mget, the last thing you could do would be to do a put of a trigger file. Have a script look for that trigger file. When it finds it, run the code below to change the extension and delete the trigger file.
I got this code from someone on Tek-Tips:
Using pure ksh:
old_ext=pl
new_ext=pm
for file in $(ls *.$old_ext)
do
mv $file ${file%${old_ext}}${new_ext}
done
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.