none
unable to skip folder RRS feed

  • General discussion

  • @Echo Off Set "dirSrc=C:\Users\garang\Documents\input_files" Set "dirDst=Archive" Set "extSrc=*.xlsx" CD /D "%dirSrc%" 2>Nul || Exit /B For /D %%A In (*) Do (PushD "%%A" For /F "Skip=1 Delims=" %%B In ( 'Dir /B/A-D-H-L-S/O-D/TW "%extSrc%" 2^>Nul') Do ( If Not Exist "%dirDst%\" MD "%dirDst%" Move /Y "%%B" "%dirDst%">Nul 2>&1) PopD) 


    i created a script for moving files from input_files folder except last modified date but unable to exclude two files from it
    i wanted to exclude /XF "Advisory Rate mapping.xlsx" "Quick_OPU_listing.xlsx" from Advisory_Rate folder in source destination path but unable to do so

    • Changed type Bill_Stewart Tuesday, July 10, 2018 8:00 PM
    • Moved by Bill_Stewart Tuesday, July 10, 2018 8:01 PM This is not "scripts on demand"
    Friday, June 22, 2018 7:52 AM

All replies

  • The is no such command parameter as /XF


    \_(ツ)_/

    Friday, June 22, 2018 8:13 AM
  •  just tried /exclude as well but not working
    the requirement was to move all the files from c:\folder1\ to c:\folder1\archive except last modified date  and except "Advisory Rate mapping.xlsx"
     "Quick_OPU_listing.xlsx"  these two files but able to with last  date and not with files
    




    • Edited by RUPESH1234 Friday, June 22, 2018 9:15 AM
    Friday, June 22, 2018 9:06 AM
  • Please stop posting formatted text as it cannot be read in most browsers.  You post is just html format lines that are u readable.


    \_(ツ)_/

    Friday, June 22, 2018 9:09 AM
  • done

    Friday, June 22, 2018 9:16 AM
  • You can use robocopy also to move files. And there you have the option to exclude files or folders with /XF or /XD.

    Take a look at the help for help.  ;-)

    robocopy /?


    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Friday, June 22, 2018 9:24 AM
  • do you understand the script or you are just replying?
    Friday, June 22, 2018 9:28 AM
  • do you understand the script or you are just replying?

    What script?  You have not posted a script.  None of your posts are made correctly.  And there is no readable code.


    \_(ツ)_/

    Friday, June 22, 2018 9:30 AM
  • @Echo Off Set "dirSrc=C:\Users\garang\Documents\input_files"

    Set "dirDst=Archive" Set "extSrc=*.xlsx"

    CD /D "%dirSrc%" 2>Nul || Exit /B For /D %%A In (*)

    Do (PushD "%%A" For /F "Skip=1 Delims=" %%B In ( 'Dir /B/A-D-H-L-S/O-D/TW "%extSrc%" 2^>Nul') Do ( If Not Exist "%dirDst%\" MD "%dirDst%" Move /Y "%%B" "%dirDst%">Nul 2>&1) PopD) 

    again posting for your information

    Friday, June 22, 2018 9:46 AM
  • Why do you keep posting formatted text.  If it is code use the code posting tool  provided on the edit tool bar.

    As I noted in the first reply.  There is no /exclude or /XF in "MOVE".  Use RoboCopy.

    For instructions on how to use RoboCopy:

    RoboCopy /?


    \_(ツ)_/

    Friday, June 22, 2018 9:50 AM
  • do you understand the script or you are just replying?

    Did you understand that you dont need a script at all to achive what you want?

    Please take a look at the help for robocopy. You can specify the source, the target, files or folders to exclude and even a maximum or minimum age for the files you want to copy or move. You only need ONE SINGLE command line - NO SCRIPT!!


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Friday, June 22, 2018 10:18 AM
    Friday, June 22, 2018 10:18 AM
  • files needs to be move from four folders...how to use logic for exclude the files for max last modified date in this

    robocopy D:\ram\one1\  D:\ram\one\two1\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    robocopy D:\ram\one2\  D:\ram\one\two2\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    robocopy D:\ram\one3\  D:\ram\one\two3\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    robocopy D:\ram\one4\  D:\ram\one\two4\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    thanks


    • Edited by RUPESH1234 Friday, June 22, 2018 11:40 AM
    Friday, June 22, 2018 11:39 AM
  • suggestion please
    Saturday, June 23, 2018 9:13 AM
  • Suggestion plesae
    Saturday, June 23, 2018 9:42 AM
  • See:

    XCOPY /?

    XCOPY source destination /EXCLUDE:file1+file2+file3...


    \_(ツ)_/

    Saturday, June 23, 2018 6:26 PM
  • I am asking for last modified date file logic in exclude condition rest I am fine with query


    • Edited by RUPESH1234 Sunday, June 24, 2018 6:19 AM
    Sunday, June 24, 2018 6:15 AM
  • I am asking for last modified date file logic in exclude condition rest I am fine with query


    As I  noted before there is no such thing in Move/copy or xcopy.  Only RoboCopy allows for that.

    See RoboCopy help for details:

    RoboCopy /?

    You can also use PowerShell to do what you ask.


    \_(ツ)_/

    Sunday, June 24, 2018 7:19 AM
  • I know robocopy ...can you help me with last modified date file to be excluded from the copy
    Sunday, June 24, 2018 7:51 AM
  • I know robocopy

    Cool. Then you probably know as well, that this

    ... last modified date file to be excluded from the copy

    .. does not exist out of the box. You would have to determine before your run robocopy with Powershell wich file to exclude. BTW: Your example folders you mentioned above do not make that much sense. If you'd have formattted it correctly you might see it by yourself

    robocopy D:\ram\one1\  D:\ram\one\two1\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017
    robocopy D:\ram\one2\  D:\ram\one\two2\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017
    robocopy D:\ram\one3\  D:\ram\one\two3\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017
    robocopy D:\ram\one4\  D:\ram\one\two4\ /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    The folder you want to exclude is not even in the folder you want to move!! And you actually reproduce the same folder strukture in the target again. You could make you live easier when you start the copy or move job one folder level above like this:

    robocopy D:\ram\       D:\ram\one\      /MOVE /xd D:\ram\one\Demand_Tracker_15112017

    To determine the last modified file in a folder you can use this simple Powershell code

    Get-ChildItem -Path 'desired path' -Filter *.* |
        Sort-Object -Property LastWriteTime |
            Select-Object -Last 1

    I urgently recommend for you to start to learn the very basics of Powershell. I'm pretty sure it would pay off for you in the future. A good and slightly entertaining starting point could be the free video course at the Microsoft Virtual Academy: Getting Started with Powershell

    Have a lot of fun!


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Sunday, June 24, 2018 11:17 AM
    Sunday, June 24, 2018 11:16 AM
  • I would just exclude the filenames from the search using the find /v command.

    @Echo Off
    Set "dirSrc=C:\Users\garang\Documents\input_files"
    Set "dirDst=Archive"
    Set "extSrc=*.xlsx"
    CD /D "%dirSrc%" 2>Nul || Exit /B
    For /D %%A In (*) Do (PushD "%%A" For /F "Skip=1 Delims=" %%B In ('"Dir /B/A-D-H-L-S/O-D/TW "%extSrc%" 2^>Nul | find /v "Advisory Rate mapping.xlsx" | find /v "Quick_OPU_listing.xlsx""') Do ( If Not Exist "%dirDst%\" MD "%dirDst%" Move /Y "%%B" "%dirDst%">Nul 2>&1) PopD)

    Sunday, June 24, 2018 12:36 PM