Skip to content

Commit ddbfc03

Browse files
committed
Add option to preserve file modification time stamp
1 parent 41d217e commit ddbfc03

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Usage: reflac [OPTION]... [--] DIRECTORY...
6666
-r --recursive Recurse into directories.
6767
-n --no-action Do not recompress. With --verbose, displays a list of
6868
files that would be processed.
69+
-p --preserve Preserve file modification time.
6970
-s --no-sync Do not synchronize file data. Will return faster, with
7071
the potential danger to lose your files in a system crash.
7172
-0 --fast Use the fastest, but worst, compression possible.

reflac

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ RECURSIVE=0
99
NOACTION=0
1010
SYNC=1
1111
FLAC_LEVEL=5 # Default FLAC compression level
12+
PRESERVE_MODTIME="" # for -p|--preserve
1213

1314
SELF="$(readlink -f "$0")"
14-
OPTS=$(getopt -o Vvhrns012345678 \
15-
-l version,verbose,help,recursive,no-action,no-sync,fast,best \
15+
OPTS=$(getopt -o Vvhrnps012345678 \
16+
-l version,verbose,help,recursive,preserve,no-action,no-sync,fast,best \
1617
-n reflac -- "$@")
1718
TMPDIR="$(mktemp --tmpdir -d reflac.XXXXXXXXXX)"
1819

@@ -35,6 +36,7 @@ Usage: reflac [OPTION]... [--] DIRECTORY...
3536
-r --recursive Recurse into directories.
3637
-n --no-action Do not recompress. With --verbose, displays a list of
3738
files that would be processed.
39+
-p --preserve Preserve file modification time.
3840
-s --no-sync Do not synchronize file data. Will return faster, with
3941
the potential danger to lose your files in a system crash.
4042
-0 --fast Use the fastest, but worst, compression possible.
@@ -72,7 +74,7 @@ recompress()
7274
"$TMPDIR/$(basename -s flac -- "$flac")rf64"
7375
fi
7476

75-
metaflac --no-utf8-convert \
77+
metaflac --no-utf8-convert $PRESERVE_MODTIME \
7678
--import-tags-from="$TMPDIR/$(basename -s flac -- "$flac")tag" \
7779
-- "$TMPDIR/$flac"
7880
mv -f -- "$TMPDIR/$flac" "$flac.new"
@@ -108,6 +110,9 @@ while true ; do
108110
-n|--no-action)
109111
NOACTION=1
110112
shift ;;
113+
-p|--preserve)
114+
PRESERVE_MODTIME="--preserve-modtime"
115+
shift ;;
111116
-s|--no-sync)
112117
SYNC=0
113118
shift ;;

reflac.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ store multiple albums or multiple discs in separate directories, you
4040
can just specify the top-level directory with the recursive option
4141
enabled.
4242

43+
*-p*, *--preserve*::
44+
Preserves file modification time stamps, where possible.
45+
4346
*-n*, *--no-action*::
4447
Do not recompress any files. Combined with the *-v* option, reflac
4548
will display a list of files it would otherwise recompress.

0 commit comments

Comments
 (0)