Create folder based on filename?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krilbe
    Visitor
    • May 2015
    • 4

    Create folder based on filename?

    I have a script to fetch files from FTP. I want to put the file in a different folder based on a date that's part of the remote file's name.

    E.g. if the remote file is named RemoteFile_2016_05_03.csv I want to put it in folder Fetched Files\2016-05-03\.

    I know how to extract the date using regex, and already use that to rename some other files, changing the date separator in the process.

    I also know I can use the create right option for the load command to create a new folder. But how can I get the extracted date into the right folder name in the load command?

    Or is there any other way to achieve this? Can rename or moveto be used in any way to do what I want?
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    There isn't a method to extract the date as text and pass this to other commands within BC Scripting. If you can obtain this value in a previous script run, you can pass it as text into a BC script with:
    bcompare.exe "@c:\bcscript.txt" "c:\folder1" "c:\folder2" "2016_05_03"

    Any text parameters after the script file can be referenced with %1, %2, %3, etc. In this case, the date text is %3 and can be referenced in script.

    load %1 %2
    expand all
    select left.newer.files left.orphan.files
    copyto left c:\destination%3\
    Aaron P Scooter Software

    Comment

    Working...