LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Move directory of files (https://www.linuxquestions.org/questions/linux-newbie-8/move-directory-of-files-652839/)

siva19185 07-01-2008 10:28 AM

Move directory of files
 
I have series of files

one.txt two.txt three.txt four.txt and so on into the directory TXT,

I want to move these files to TXT.BACKUP directory like

one.txt.backup two.txt.backup three.txt.backup four.txt.backup....

can anyone guide me......

stress_junkie 07-01-2008 11:28 AM

If you have a backup directory then you probably don't need to rename every file in the backup directory. I would do this.
Code:

cp -R TXT TXT.BACKUP

jschiwal 07-01-2008 11:41 AM

It will probably work best if you cd into your TXT directory.

Code:

cd TXT
  for file in *.txt; do
  mv "$file" ../TXT.BACKUP/"${file}.backup"
done

Since you want to move them instead of making a copy, adding .backup at the end seems odd to me because the originals are deleted.

After the "in" in the for loop you could have a space separated list of files if there are a handful of particular files that you want to backup:
for file in one.txt two.txt three.txt

siva19185 07-02-2008 02:59 AM

Thank u pals...

It's work very well..


All times are GMT -5. The time now is 02:46 AM.