Sunday, May 14, 2017

removing file extensions for a group of files

Below are the couple of ways with which we can replace/remove a file extension for a group of files.

i.e renaming a file from "abcxyz.processed" to "abcxyz".


method 1:

for file in *processed
do
    mv -i "${file}" "${file/.processed/}"
done



method 2:

find . -name "*.processed" -exec rename 's/.processed$//' {} \;

No comments:

Post a Comment