+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, Need a batch files/VB script to find file extensions with conditions in Coding and Web Development; Help: Need a batch files/VB script to find file extensions with conditions I haven't been able to find a program ...
  1. #1

    Join Date
    Feb 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Need a batch files/VB script to find file extensions with conditions

    Help: Need a batch files/VB script to find file extensions with conditions
    I haven't been able to find a program to do this as not quite a "find duplicate file" scenario. Can anyone help?

    Scenario:
    I need to convert drawings from .pdf to .tiff/tif to be able to import into another program.
    However, I often also receive the drawing as a .tiff so don't always have a corresponding .pdf.
    Otherwise it would be a simple solution of deleting all .tiff.

    I have about 3500 project folders, with a squillion subfolders, and backups are getting too large. If I could filter out the duplicate .tiff, that would significantly reduce the total space required.

    Hence, I want to be able to search for and then move all .tiff/tif files to the local recycle bin (ie delete), where there is a matching .pdf in that subfolder location. (reduce size of backups)


    So ideally the location/file path will be part of the file name for finding duplicates, as the file name may not necessarily be unique, and then examine the file extension to find "duplicates".


    Example files:

    1 d:\projects\House1\floorplan.pdf
    2 d:\projects\House1\floorplan.tif
    3 d:\projects\House2\floorplan.pdf
    4 d:\projects\House2\floorplan.tif
    5 d:\projects\House2\revised plan\floorplan.tif
    6 d:\projects\House3\floorplan.pdf
    7 d:\projects\House3\floorplan.tif

    Result:

    I would only want to find (and then delete) files 2,4&7

    I don't want to delete file 5 as there is no matching .pdf in that subfolder...


    No file finder software can do this (as far as I can see)


    A bonus would be to include a variable to search only files older than say 3months....


    Can anyone assist?


    Thanks in advance.

  2. #2
    TheLibrarian
    Guest
    Code:
    for /f "delims=*" %i in ( 'dir /b *.pdf') do @echo "%~di%~pi%~ni.tif"
    You should be able to modify that to get rid of the tif / tiff files you no longer want.

  3. #3

    Join Date
    Feb 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks Librarian for taking the time to answer.

    My skills are very limited in this area, so I don't know how to get this to work.
    Obviously I need some move to recycle bin commands or delete commands in there too....

    wondering if 'dir /b *.pdf' should use 'dir /b /s *.pdf'
    as i don't want to run this in each subfolder....

  4. #4
    TheLibrarian
    Guest
    Glad I could help.

    The dir command could take the /s switch, definitely.

    When you are certain the echo command is outputting the filenames and paths you want then change the "echo"command to "del /q".

    I didn't enter the del command in the post to ensure the commands executed were not destructive in case they weren't right.

  5. #5

    Join Date
    Feb 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks for suggestions.

    I endedup with a solution using a script in XYplorer.

    Works a treat.



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 09:34 AM
  2. Script to Find and Replace within an INI file.
    By timethrow in forum Scripts
    Replies: 1
    Last Post: 4th February 2012, 11:17 AM
  3. Replies: 0
    Last Post: 6th July 2011, 12:24 AM
  4. Replies: 13
    Last Post: 22nd April 2011, 04:50 PM
  5. Replies: 4
    Last Post: 25th December 2006, 10:15 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •