Oramcle
asked on
Rename Multiple file in Unix
I have accidentally Rename more than 100 files in one Folder in Unix like
File_Namee to July_2016_FIle_name Like all the file prefixed to same String "july_2016_" How can I Reverse this action through Script?
Thank you Very Much.
File_Namee to July_2016_FIle_name Like all the file prefixed to same String "july_2016_" How can I Reverse this action through Script?
Thank you Very Much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Oramcle,
Reason for using script:
1. Validate existence of related commands (/bin/mv /usr/bin/find....
2. While renaming using /bin/mv -i for handling exception: if destination file is present
3. Handle exception to /usr/bin/find at related directory instead of / => performance and related path
4. If already renamed, display related alert message "Unable to find July_2016.....
5. Same script can be used if facing similar issue (which can be used to enhance or modify based on current or new requirement)
6. Using /usr/bin/find command for searching all related files at required directory and it's sub directories
You can use following command to handle exceptions:
/usr/bin/find ..... 2>/dev/null
Reason for using script:
1. Validate existence of related commands (/bin/mv /usr/bin/find....
2. While renaming using /bin/mv -i for handling exception: if destination file is present
3. Handle exception to /usr/bin/find at related directory instead of / => performance and related path
4. If already renamed, display related alert message "Unable to find July_2016.....
5. Same script can be used if facing similar issue (which can be used to enhance or modify based on current or new requirement)
6. Using /usr/bin/find command for searching all related files at required directory and it's sub directories
You can use following command to handle exceptions:
/usr/bin/find ..... 2>/dev/null
Using the "quick" approach you can learn a lot how Unix sytems work -- end even learn to use powerful renaming tools like "RegExRenamer" on Windows ;-)
Anyway, it always depends on the level of experience a user has ...
Anyway, it always depends on the level of experience a user has ...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Experts.
Oramcle.
Oramcle.
Related code:
Updated script including exceptions:
Open in new window
Sample output:Open in new window
Open in new window