Skip to main content
added 198 characters in body
Source Link

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 8084 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv -{T,--b=t} "$0" "${0// }"' {} \;

bash/find/mv 7882 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv -{T,-b=t} "$0" "${0// }"' {} \;

Cuddled && to save two space bytes.

bash/find/mv 5660 bytes, 11 spaces

find -d -execdir bash -c 'mv -{T,-b=t} "$0" "${0// }"' {} \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

Edit: Dropped the quotes from {} as reminded by Dennis. Also allowed find to scream about portability and deprecation in the shortest version where mv is already screaming about moving a file on top of itself.

Edit 2: Added -T to mv command to avoid nesting directories instead of renaming as pointed out by pqnet. Used brace expansion at cost of one character over just using one space.

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 80 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv --b=t "$0" "${0// }"' {} \;

bash/find/mv 78 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv --b=t "$0" "${0// }"' {} \;

Cuddled && to save two space bytes.

bash/find/mv 56 bytes, 11 spaces

find -d -execdir bash -c 'mv --b=t "$0" "${0// }"' {} \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

Edit: Dropped the quotes from {} as reminded by Dennis. Also allowed find to scream about portability and deprecation in the shortest version where mv is already screaming about moving a file on top of itself.

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 84 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv -{T,--b=t} "$0" "${0// }"' {} \;

bash/find/mv 82 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv -{T,-b=t} "$0" "${0// }"' {} \;

Cuddled && to save two space bytes.

bash/find/mv 60 bytes, 11 spaces

find -d -execdir bash -c 'mv -{T,-b=t} "$0" "${0// }"' {} \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

Edit: Dropped the quotes from {} as reminded by Dennis. Also allowed find to scream about portability and deprecation in the shortest version where mv is already screaming about moving a file on top of itself.

Edit 2: Added -T to mv command to avoid nesting directories instead of renaming as pointed out by pqnet. Used brace expansion at cost of one character over just using one space.

Included improvements suggested by Dennis.
Source Link

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 8280 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv --b=t "$0" "${0// }"' '{}' \;

bash/find/mv 8078 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv --b=t "$0" "${0// }"' '{}' \;

Cuddled && to save two space bytes.

bash/find/mv 6256 bytes, 11 spaces

find -depthd -execdir bash -c 'mv --b=t "$0" "${0// }"' '{}' \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

Edit: Dropped the quotes from {} as reminded by Dennis. Also allowed find to scream about portability and deprecation in the shortest version where mv is already screaming about moving a file on top of itself.

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 82 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv --b=t "$0" "${0// }"' '{}' \;

bash/find/mv 80 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv --b=t "$0" "${0// }"' '{}' \;

Cuddled && to save two space bytes.

bash/find/mv 62 bytes, 11 spaces

find -depth -execdir bash -c 'mv --b=t "$0" "${0// }"' '{}' \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 80 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv --b=t "$0" "${0// }"' {} \;

bash/find/mv 78 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv --b=t "$0" "${0// }"' {} \;

Cuddled && to save two space bytes.

bash/find/mv 56 bytes, 11 spaces

find -d -execdir bash -c 'mv --b=t "$0" "${0// }"' {} \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.

Edit: Dropped the quotes from {} as reminded by Dennis. Also allowed find to scream about portability and deprecation in the shortest version where mv is already screaming about moving a file on top of itself.

Source Link

If the order of collided file suffixes does not need to give precedent to the pre-existing file then the following works for me:

bash/find/mv 82 bytes, 16 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ] && mv --b=t "$0" "${0// }"' '{}' \;

bash/find/mv 80 bytes, 14 spaces

find -depth -execdir bash -c '[ "${0//[^ ]}" ]&&mv --b=t "$0" "${0// }"' '{}' \;

Cuddled && to save two space bytes.

bash/find/mv 62 bytes, 11 spaces

find -depth -execdir bash -c 'mv --b=t "$0" "${0// }"' '{}' \;

Drops error protection so it gets errors from mv on files which have no spaces to start with.