Demonstrate techniques for generating and renaming files.
TODO:
- Changing file extensions
find . -name "*.js" -exec sh -c 'mv "$1" "${1%.js}.ts"' _ {} \;
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
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 {} {.}