Skip to content

Commit

Permalink
remove_date_prefix: Add dry run option
Browse files Browse the repository at this point in the history
  • Loading branch information
kaeff committed May 20, 2024
1 parent 2568e87 commit 46aeb80
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion remove_date_prefix
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
#!/bin/bash

dry_run=false

while getopts "f" opt; do
case $opt in
f)
dry_run=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

for file in *; do
if [[ -f $file ]]; then
newfile=$(echo $file | sed 's/^[0-9_-]*//')
mv "$file" "$newfile"
if $dry_run; then
echo "mv \"$file\" \"$newfile\""
else
mv "$file" "$newfile"
fi
fi
done

0 comments on commit 46aeb80

Please sign in to comment.