Search code examples
bashmacosrangeleading-zerobrace-expansion

Delete files from 00012 to 00441 using Terminal


This is my Bash version: 3.2.57(1)-release

I found that this MIGHT possible using terminal rm code, but it doesn't work for me

Here is a picture of the first files: Picture of a bunch of Files

Typing rm _{00012..00441} I get this error: Terminal Error

Seems like the code us unable to use the leading zeros since is trying to find the files like 12,13,14,15, instead of 00012,00013,00014,00015

To make things more difficult, the last file in the range has a different amount of leading zeros, so using rm _000{ wont work

In trying to use AppleScript to run this as

do shell script ("rm  _{" & STARTrange & ".." & ENDrange & "}.psd")

Solution

  • Thanks to Cyrus I made this work. The answer in OSX is to install the latest version of Bash using homebrew.

    Using this guide I was able to change the default Bash from terminal to the one Homebre installs: https://apple.stackexchange.com/questions/193411/update-bash-to-version-4-0-on-osx

    Thanks