Batch Script to move specific ext

Discussion in 'Programming/Html' started by matrixebiz, Jul 22, 2021.

  1. matrixebiz

    matrixebiz Guest

    Messages:
    2
    Likes Received:
    2
    GPU:
    16GB
    Good Day, I'm running Windows 10 and searched a few threads but didn't fine one specific to my needs so hoping someone could help me out.

    What I would like is a batch script to search a folder and all it's subfolders for a specific file ext of my choosing, for example *.onetoc2 and move it to a Temp directory of my choosing creating the same folder name structure within it of where the original came from just incase I need to move the files back to their original location. Thank you
     
    TimmyP likes this.
  2. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,666
    Likes Received:
    13,665
    GPU:
    GF RTX 4070
    It would be easier to write such PowerShell script (since PowerShell has full scale programming language).

    Also in case files in different subfolders will not have the same names there is another possibility - to copy found files to temp folder and create a batch file to copy those files back to original place. That will be easier to implement in batch script.
     
  3. matrixebiz

    matrixebiz Guest

    Messages:
    2
    Likes Received:
    2
    GPU:
    16GB
    Okay, thanks, looks like a simple robocopy command will do what I want;
    robocopy "C:\My Source" "C:\My Destination" *.onetoc2 /S /MOV
     
    TimmyP likes this.
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,666
    Likes Received:
    13,665
    GPU:
    GF RTX 4070

Share This Page