Windows 10: Batch file to search directory for file type and copy to new location

Discus and support Batch file to search directory for file type and copy to new location in Windows 10 Support to solve the problem; Hi all, Not sure if posting in correct area, I would like to have a batch file that can search a directory or drive for file type and copy that file... Discussion in 'Windows 10 Support' started by John Foster, Mar 5, 2020.

  1. Batch file to search directory for file type and copy to new location


    Hi all,

    Not sure if posting in correct area, I would like to have a batch file that can search a directory or drive for file type and copy that file into a new directory renaming the file to reflect what users folder it came out of.

    To be a little more specific, I have multiple systems all Windows 10 ver 1909, most likely multiple user profiles on each. My task is to get all the old PST files from these systems copy to a central location then use Azure import to upload and archive into Office 365 users online archive.

    I am confident that the first part can be done through Batch file, as most pst files are labelled outlook.pst, I would like it to copy to new location and rename the file to the username of the users profile the pst file came out of, but also if there are multiple outlook.pst for same user it might be wise to append 1,2,3 etc.

    E.g.

    Old system: New location:
    c:\users\Joe.Blogs\outlook files\outlook.pst F:\PSTfiles\Joe.blogs\joe.blogs.pst
    c:\users\Jane.Blogs\outlook files\outlook.pst F:\PSTfiles\Jane.blogs\jane.blogs.pst
    c:\users\Joe.Blogs\outlook files\office.pst F:\PSTfiles\Joe.blogs\joe.blogs1.pst
    c:\users\Joe.Blogs\outlook files\joe.blogs.pst F:\PSTfiles\Joe.blogs\joe.blogs2.pst
    c:\users\Joe.Blogs\outlook files\joe.blogsnewprofile.pst F:\PSTfiles\Joe.blogs\joe.blogs3.pst

    Ideally, it would be really good to be able to run this batch file and it stores pst to a network location (permissions would be configured to allow this)

    I also have a cupboard of drives that I would ideally like to connect to a desktop machine and target the search on that drive.

    I hope this makes sense? Can anyone help?

    Many thanks

    John

    :)
     
    John Foster, Mar 5, 2020
    #1
  2. oily_17 Win User

    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Mar 5, 2020
    #2
  3. Batch Files Knowledge Base

    Very nice and usefull thanks for contributing.
     
    AphexDreamer, Mar 5, 2020
    #3
  4. Ehstii Win User

    Batch file to search directory for file type and copy to new location

    help with simple batch file

    copy and paste this into notepad, and save as .bat



    example:

    @echo off
    xcopy /c /d /f /k /s /y "c:\my music" e:\music



    just replace it with the correct locations.

    and when you run the batch file it will ask you if you want to copy the the file, or the directory. just type "D" for directory and your good to go.
     
    Ehstii, Mar 5, 2020
    #4
Thema:

Batch file to search directory for file type and copy to new location

Loading...
  1. Batch file to search directory for file type and copy to new location - Similar Threads - Batch file search

  2. Copying files into WindowsApps directory

    in Windows 10 Gaming
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  3. Copying files into WindowsApps directory

    in Windows 10 Network and Sharing
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  4. Copying files into WindowsApps directory

    in Windows 10 Software and Apps
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  5. Can Robocopy copy in batches of files?

    in Windows 10 Gaming
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  6. Can Robocopy copy in batches of files?

    in Windows 10 Software and Apps
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  7. Can Robocopy copy in batches of files?

    in Windows 10 Network and Sharing
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  8. Trying to move/copy multiple files to new directory

    in Windows 10 Support
    Trying to move/copy multiple files to new directory: For a couple of decades I have copied or moved multiple files at a time by holding down the SHIFT KEY, selecting the files, them moving or copying. I don't know if it is the newer faster machines or Widows sensitivity or just in a hurry to get ahead of me and OPENING the...
  9. Copying files into WindowsApps directory

    in Windows 10 Network and Sharing
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  10. File History Not Copying All Files and Directories

    in Windows 10 Installation and Upgrade
    File History Not Copying All Files and Directories: I have windows 10 version 1803, and noticed today that the directory structure set up on my external hard drive by File History is different to the directory structure it is supposed to be copying across, in that there are many sub-directories missing. Some of the missing...