[Request] help making powershell script for a bulk move

Discussion in 'Scripting' started by lildude491, Jan 21, 2016.

  1. lildude491

    lildude491 MDL Novice

    Sep 6, 2012
    4
    0
    0
    Hello, Long time lurker here. I am in a bit of a bind, and thought that one of the genius minds at mdl might be able to help me out.

    I need to figure out away to move or copy the red highlighted items into a newly created sub directory green based on a string.

    E:/EasyDent4/File Server/Files/Sub013011/p20130115_094721_0000.BMP
    E:/EasyDent4/File Server/Files/Sub013022/c20130227_160800_0000.BMP
    E:/EasyDent4/File Server/Files/Sub012100/c20121003_152539_0000.BMP


    i need something to say looking inside E:/EasyDent4/File Server/Files/ for file ending in (red) xxxxx.bmp and if its found create (green) directory and copy or move file into there.

    Hope i explained this well enough and that someone is willing to share their knowledge.

    Thank you
     
  2. sebus

    sebus MDL Guru

    Jul 23, 2008
    5,879
    1,773
    180
    How does the naming of RED corresponds to naming of GREEN. I see no correlation
     
  3. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    115
    281
    10
    #3 wk-952, Jan 23, 2016
    Last edited by a moderator: Apr 20, 2017
    @lildude491
    I know you asked for a powershell script and i wanted to help you, but my knowledge in powershell is 0,
    so i made you a batch script instead, if you're interested. (change extension to .bat)

    Edit the script and change the 2 vars 'base_dir' and 'target_ext' as needed.
    If you want to copy the files instead of moving them, just change the move command at:
    Code:
    move /y "%current_file%" "%subDir%\%current_file%" >nul 2>&1 && (
    
    View attachment specific_move.txt
     
  4. glego

    glego MDL Novice

    Jan 23, 2016
    3
    1
    0
    Hi lildude491,

    Long time viewer and my first contribution. I actually had another account but somehow could not post with that one.

    Anway, I hope you like the powershell script I wrote attached. Just change the .txt to .ps1 and you can edit it using Powershell ISE.

    Have fun!

    View attachment Move-FilesBasedOnFilename.txt

    Best Regards,
    Glego
     
  5. lildude491

    lildude491 MDL Novice

    Sep 6, 2012
    4
    0
    0
    @wk-952 and Glego

    THANK YOU SO MUCH. :worthy:

    Honestly thought the thread was just going to die off. Greatly appreciated.
    I will post the results once I have run through everything. Need to set an appointment/schedule down time with the site this is for.