On Sat, 09 Feb 2008, Roger Searle wrote: > Hi, I have a script that does a wget on a website, which is working > well. Before the wget command I am moving the folder that already exists: > > mv $HOME/documents/newsite $HOME/documents/newsite-old > > which is fine. So long as the folder newsite-old doesn't already exist > because the script had previously been run and the folder exists. If it > does, I'd get the following: > > mv: cannot move `/home/roger/documents/newsite/' to a subdirectory of > itself, `/home/roger/documents/newsite-old/newsite' > > What I would really like to do is be retaining each of the previous > copies of the newsite-old folder, and having the script append an > increasing number to the folder name each time it ran, ie newsite-old1 > then newsite-old2 etc. > > How could I modify the mv command so that it did this for me? > > Hoping this makes sense, > Roger
I suggest that your script create a new directory each time it operates. I would recommend that you incorporate the date in ISO 8601 format into your directory name. This means that file managers should by default list your directories in date order. You can add other info on for human readability purposes if you choose, Here is how I would do it; DirectoryName=/home/roger/documents/site/$(date +"%Y%m%d-%a%d%b") Cheers Ross Drummond
