Skip to main content
accept relative path directory arguments
Source Link
Metamorphic
  • 599
  • 2
  • 8
  • 17

This is a simple script based on phuclv's@phuclv's suggestion to "manually sort the files by moving them to another directory in the order you want". It doesn't recurse into subdirectories. It works for me.

$ cat =fat-reorder
#!/bin/zsh
for DIR in "$@"; do
  [[ -d "$DIR" ]] || { >&2 echo "Not a directory: $DIR"; exit 1 }
done

for DIR in "$@"; do
  (
    cd $DIR
    TMP=tmp-$RANDOM
    mkdir $TMP
    mv * $TMP/ 2>/dev/null
    mv $TMP/* .
    rmdir $TMP
  )
done

Example:

sudo fat-reorder /media/CLIPJAM/Music/

This is a simple script based on phuclv's suggestion to "manually sort the files by moving them to another directory in the order you want". It doesn't recurse into subdirectories. It works for me.

$ cat =fat-reorder
#!/bin/zsh
for DIR in "$@"; do
  [[ -d "$DIR" ]] || { >&2 echo "Not a directory: $DIR"; exit 1 }
done

for DIR in "$@"; do
  cd $DIR
  TMP=tmp-$RANDOM
  mkdir $TMP
  mv * $TMP/ 2>/dev/null
  mv $TMP/* .
  rmdir $TMP
done

Example:

sudo fat-reorder /media/CLIPJAM/Music/

This is a simple script based on @phuclv's suggestion to "manually sort the files by moving them to another directory in the order you want". It doesn't recurse into subdirectories. It works for me.

$ cat =fat-reorder
#!/bin/zsh
for DIR in "$@"; do
  [[ -d "$DIR" ]] || { >&2 echo "Not a directory: $DIR"; exit 1 }
done

for DIR in "$@"; do
  (
    cd $DIR
    TMP=tmp-$RANDOM
    mkdir $TMP
    mv * $TMP/ 2>/dev/null
    mv $TMP/* .
    rmdir $TMP
  )
done

Example:

sudo fat-reorder /media/CLIPJAM/Music/
Source Link
Metamorphic
  • 599
  • 2
  • 8
  • 17

This is a simple script based on phuclv's suggestion to "manually sort the files by moving them to another directory in the order you want". It doesn't recurse into subdirectories. It works for me.

$ cat =fat-reorder
#!/bin/zsh
for DIR in "$@"; do
  [[ -d "$DIR" ]] || { >&2 echo "Not a directory: $DIR"; exit 1 }
done

for DIR in "$@"; do
  cd $DIR
  TMP=tmp-$RANDOM
  mkdir $TMP
  mv * $TMP/ 2>/dev/null
  mv $TMP/* .
  rmdir $TMP
done

Example:

sudo fat-reorder /media/CLIPJAM/Music/