Jump to content
The mkiv Supra Owners Club

DOS scripts


Chris Wilson

Recommended Posts

I want to write a script that will delete files in a directory that are duplicates. The duplicates have (for example) the name chevron[1].jpg

 

or chevron[2].jpg

 

the original being say chevron.jpg

 

How can I write a single script to delete the [1] [2] [3] et cetera dupes?

 

I can do any one by

 

del *[1]*.jpg

 

but not sure how to do the [2] [3] et cetera with one script and make it run contiguously.

 

I have got this mess by carelessly adding the same files to a directory with an app that adds [1] to the first dupe [2] to the next and so on.

Link to comment
Share on other sites

You might be able to test by doing dir *[?]*.jpg which will list the matching files.

 

Yup, I'm not 100% sure because I'm having to think in regex and do a little conversion

 

for i in [1 2 3 4 5 6 7 8 9 10] do

rm -f cetron$i

done

But then I'm just geeky, Chris ignore the above snippit as it won't work in DOS :)

Link to comment
Share on other sites

* is difficult to use, as it'll look for anything before the '.'. '?' can be used to define a wildcard single space, but that leads to looong scripts if you can't predict the location of the '[1]'. I'm sure someone intelligent will be along soon to sort this. I may have a crack at it later :-)

 

I suspect the easiest way is to export a list of files in a directory to a file, and pipe '

 

Then again, if you could sort by date to organize dupes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. You might also be interested in our Guidelines, Privacy Policy and Terms of Use.