Posted: 2007-06-20 14:06
perhaps somebody can help me with my problem. The main problem is that i want to move some remote files from one directory to another. If the files are already in the target directory i want to overwrite them. This task is part of a script and the number of the files to move can be different.
It is possible that some files in the target directory should stay there and other files should be replaced. For example i want to move/replace the files 'file1.txt' and 'file2.txt' and the existing file 'file3.txt' should be unchanged. With the mv-command i get an error because the files are already there.
Then i added a delete-step before i moved the files, but then i got an error, if the file, which i want to delete, does not exist.
Now i think the only way is to check for each moving-file, if the file exists in the target directory. If it exists i have to delete it and after this i can move the source file. But to check, if the file exists seems to be a new problem.
This normally simple task seems to be a problem for me. Perhaps can't see the simple solution and somebody can give me a hint.
Thanks for help
Location: Prague, Czechia
You can set "option batch continue" before the "rm" command to avoid the script be interrupted on error.
You can post new topics in this forum
And it's free!