Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.06 KB

File metadata and controls

46 lines (33 loc) · 1.06 KB

GENERATING AND RENAMING

Demonstrate techniques for generating and renaming files.

TODO:

  • Changing file extensions find . -name "*.js" -exec sh -c 'mv "$1" "${1%.js}.ts"' _ {} \;

Examples (generation)

Generate a bunch of files with leading zeros.

file="file"
extension="txt"
outpath="./out/"
mkdir -p ${outpath}
for index in $(seq 0 10); 
do
    filepath=`printf %s%s%04d.%s ${outpath} ${file} ${index} ${extension}`
    echo "Creating ${filepath}"
    touch $filepath
    sleep 1
done

Examples (renaming)

Use fd Ref: ../24_finding_files/README.md

# show text files (generated above)  
fd -e txt . './out'

# renaming extensions  
fd -e txt . './out' -x mv {} {.}.text

# removing extension
fd -e m4a . './out' -x mv {} {.}  

Resources

  • Add Leading Zeros to File Names here
  • Renaming Linux Files in Batches here
  • sharkdp/fd repo here