Results 1 to 3 of 3
Hi, if i have these files in this structure:
/folder1/folder2/afile.20070501
/folder1/folder3/afile.20070501
/folder1/folder4/afile.20070501
/folder2/folder5/afile.20070501
/folder2/folder6/afile.20070501
I don't know *all* the location of all the files - there may be more or ...
- 05-14-2007 #1Just Joined!
- Join Date
- May 2007
- Posts
- 3
Rename files while preserving directories
Hi, if i have these files in this structure:
/folder1/folder2/afile.20070501
/folder1/folder3/afile.20070501
/folder1/folder4/afile.20070501
/folder2/folder5/afile.20070501
/folder2/folder6/afile.20070501
I don't know *all* the location of all the files - there may be more or less.
I would like to remove the '.20070501' extension from all the files while keeping the files in the same directory.
Thanks
- 05-14-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
here's one way:
Code:find /path -type f -name "*.20070501" > file while read -r line; do mv "$line" "${line%%.*}" done < file
- 05-14-2007 #3


Reply With Quote
