• Want app to delete same file on 2 other drives when I delete file on first drive

    Home » Forums » AskWoody support » Windows » Windows 10 » Windows 10 version 21H2 – November 2021 Update » Want app to delete same file on 2 other drives when I delete file on first drive

    Author
    Topic
    #2447572

    Since around 2014 I have been using smart phones, mainly Samsung Galaxy models. I take a LOT of pictures (too many). I don’t like automatic backup/cloud copy algorithms. Instead, periodically I copy pictures from the phone to the OneDrive folder on my Dell Inspiron desktop running Windows 10. I also have an external Western Digital USB backup drive to which I backup/copy files periodically using Beyond Compare (currently I have a license for BC4). I also recently replaced the 1TB SATA drive in the PC with a 2TB SSD and copied the OneDrive folder over to the new drive with the old (SATA) drive in a USB drive dock.

    I want to delete old photos that I don’t want to keep from my current phone, a Samsung Galaxy S9+ as the SD card is getting full, and at the same time delete those photos from the Western Digital USB backup drive, the current SSD boot drive and the old system (SATA) drive in the drive dock.

    I can’t use a duplicate file/image finder app because I want to connect the phone to the computer via USB and view the photos in Windows Explorer (using View > Extra Large) to decide which photos to delete and delete them manually. So for example if I delete a file on the phone with the title “20210101_100724.jpg” I want the app to find the file with that exact name on the other three drives and delete it there also. The app or method or script should allow me to select more than one image and it will delete all of them on the other drives.

    Also, I have already deleted files earlier than 2019 on the phone so once I delete all the images on the phone that I no longer want, I will need to move on to the SSD drive where I have images stored back to 2014 and use that drive as the master, where I will view and manually delete the files.

    Thanks,
    Don

    Viewing 6 reply threads
    Author
    Replies
    • #2447584

      Backup Software for Everyone’s Budget. SyncBackFree, SyncBackSE & SyncBackPro (2brightsparks.com)

      I’m not sure I’ve seen a sync solution that can handle more than one drive at a time, I wonder if you could set up one drive the way you want and then ‘sync’ the results to the other locations?  You can set up sync programs to delete items not on the syncing drive.

      Susan Bradley Patch Lady

    • #2447660

      Make a dir listing before doing anything (dir /b).
      Drop the list in a spreadsheet.
      Delete the unwanted files.
      Make a new dir list.
      Add it to the spreadsheet and filter for unique names.
      Copy the unique names and add the required delete command(s)  to the cell before the file names.
      Copy the two columns to an editor (Notepad) and save as a BAT file.

      Run the bat file to delete the unwanted files.

      cheers, Paul

      • #2447781

        In principal this seems workable but the challenge is that the path to each image file will not only have a different drive letter (not so hard to manage) but it will almost certainly be in a folder with a considerably different path. Here is an example of one image file from the phone. I searched for that file name on the respective drives. I first connected the phone to find the file of interest then disconnected the phone and connected the WD backup drive (E:\ below) and the old SATA drive (F:\ below). I guess I will just have to do it iteratively based on the respective path where each file is located. I think that files from certain years will be in the same folders since I have partitioned them that way on the drives, so that would make it a little easier.

        On the phone
        This PC\Don’s Galaxy S9+\Card\DCIM\Camera\20200706_172520.jpg

        On the computer (SSD)
        C:\Users\Don\OneDrive\Documents\Samsung Galaxy S5 and S9 Pictures\2020\20200706_172520.jpg

        On the Western Digital backup drive
        E:\1DriveBackup\Documents\Samsung Galaxy S5 and S9 Pictures\2020\20200706_172520.jpg

        On the old system drive (SATA)
        F:\Users\Don\OneDrive\Documents\Samsung Galaxy S5 and S9 Pictures\2020\20200706_172520.jpg

        Don

    • #2447865

      I can’t use a duplicate file/image finder app because I want to connect the phone to the computer via USB and view the photos in Windows Explorer (using View > Extra Large) to decide which photos to delete and delete them manually.

      Also, I have already deleted files earlier than 2019 on the phone so once I delete all the images on the phone that I no longer want, I will need to move on to the SSD drive where I have images stored back to 2014 and use that drive as the master, where I will view and manually delete the files.

      I think that’s the fly in the ointment. You would have to very, very careful that the script or program does not think everything that’s not on the phone should be deleted. Yeah, it could be done, but it feels like you’re playing with fire and could get burned, potentially losing everything prior to 2019.

      I think I’d create a temporary “delete-these” folder, and when you’re reviewing your phone’s photos, drag them to the “delete-these” folder instead of manually deleting them outright. Once you’ve got a folder of all the master photos to be deleted, then you can use a duplicate files finder program. For all the duplicate groups that have at least one copy in the “delete-these” folder, let the program delete them and all copies found across the other disks.

       

    • #2447888

      Paths are not an issue. You can split the data in the spreadsheet using Text to Columns and the slash as the separator. This gets you down to filenames only.

      There is no easy way to do this, but I’ve used this method a lot for data transfer and it’s always fine as long as you check everything before running the batch file.

      cheers, Paul

    • #2448048

      SnoopDon,

      Here’s a little PowerShell program I whipped up which should help.
      The program when run with the -Setup switch will install a shortcut in the File Explorer right-click menu under SendTo. Once that is done you just go into File Explorer, in any one of your 4 directories, right click a file to delete select SendTo the Remove-FromMultiDirs and you’re off to the races.

      Program:

      I’ve designed the program to be quiet so you will get no notification of the deletions but they will take place. This allows you to do a lot of deletions with out answering a lot of pesky prompts to dismiss messages.

      Note: The file deletions are PERMANENT they are not moved to the Trash!!!!!

      Example:
      RemoveMultDirsJPG

      HTH

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #2448078

        You need a note about editing $MyPaths before use.

        cheers, Paul

    • #2448135

      Paul,

      You are correct. I was mainly focusing on the OP and didn’t really consider that others might need this same functionality, MY BAD!

      So to make amends here is version 2 of the program (Version 1 removed from above post).

      Program:
      File Removed see link to new location below!

      Installation:

      1. Unzip the file to the folder/directory where you want it to reside. It needs to stay here as the install function will reference this directory in the SendTo shortcut it creates!
      2. Run the program with the -Setup argument, Ex:
        [d:pathRemove-FromMultiDirs.ps1 -Setup
        You should receive this message:
        SendtoAdded
        If you try to install the program a second time you’ll get this message:
        Shortcut-already-exists
      3. Create a plain text file with your fully qualified folder/directory paths.
        One per line and you can have as many as you want. Remember to include the the one you’ll be working from. Do *** NOT *** enclose them in quotes even if they contain spaces!
        Save the file as Remove-FromMultiDirs.ini in the same folder as the Remove-FromMultiDirs.ps1 file. If the program does not find your .ini file in the same directory you’ll get this message:
        IniFileNotFoundJPG
      4. You’re all installed and ready to go!

      Note: you can get the help file for the program by opening PowerShell and entering:
      Get-Help [d:path\]Remove-FromMultiDirs.ps1 -Full

      Hope that is a little clearer.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      1 user thanked author for this post.
      • #2448194

        Hi RetiredGeek,

        Thanks for doing this. I am pretty busy right now mowing my 30,000 square foot lawn as we had sun today (but rain tonight) and tomorrow is supposed to be dry and I’ve only gotten about 25% of it mowed so I’ll be busy doing that tomorrow. I’m not sure I understand your script but will take a look at it when I have time. I would prefer actually that it be verbose and let me know what it is doing so I can make sure I’m not deleting more files than I expected. Also, is it possible for the script to put the deleted files in the Recycle Bin so I can undelete them if I delete some files erroneously?

        Thanks,
        Don

    • #2448329

      Ok Don,

      You Asked for it!

      Version: 3-2-2

      Changes:

      1. Files are now moved to Trash for possible recovery. With the exception of any files deleted from a mapped drive!
      2. A list of files selected for deletion is written to a file in your Documents directory with a naming pattern of: Removed Files as of yyyymmdd.txt. The file will be appended to if you do more than one deletion on the same day. Old files will need to be manually deleted when you decide they are no longer needed.
      3. Code has been optimized to make as efficient as possible given the necessary work-a-rounds for the Trash file and to reduce redundant code.
      4. The in-line help has been updated to include the changes and clarify the workings of the program.

      Sample Remove-FromMultiDirs.ini:

      G:\Test
      G:\Test\Dir 3
      G:\Test\Dir1
      z:\Test
      y:\Test
      

      Sample Output File: Removed Files as of 20220522

      G:\Test\Dir 3\Apple-123.txt
      G:\Test\Dir1\Apple-123.txt
      G:\Test\Dir2\Apple-123.txt
      G:\Test\Apple-123.txt
      Z:\Test\Apple-123.txt
      

      The program can be found on my One Drive Shared Area. You can check here for any updates as you feel the need.

      One update I’m considering is to include a proper .ini file which will allow the user to specify more program options. Stay tuned!

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    Viewing 6 reply threads
    Reply To: Want app to delete same file on 2 other drives when I delete file on first drive

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: