Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2014
    Posts
    9

    Question Single File Copy

    So I honestly feel very silly posting this, although it's been bugging me and I can't fathom there is no way to do this. I have written several scripts that compare and copy multiple files, as well as one that will do a single file compare and output the results to html. No problem. But for the life of me I can't seem to write a script that will simply copy a single file from a to b. Here is the script that I have..

    log verbose %3
    criteria binary
    filter %4
    load %1 %2
    copy left->right

    and the command to run it would be

    BComp @<script> <left path> <right path> <log file> <file name>

    When running it, I get no errors, but the file is also not copied.

    Comparing the two manually inside of BC, it shows differences in the file, before and after running. Comparing the two files using a similar script, shows the differences in the file. Leaving out the filter command, adding an expand all and select all will get the file copied, but obviously also copies everything else. Now, I have realized that I wouldn't really need BC to do this file copy (I could use standard command line copy, but the rest of the actions in this library use it, and I already have code surrounding parsing the log file and displaying the results in a customized way.

    So, is there a way to do what I want to do using BC scripts?

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,788

    Default

    Yes, the copy command needs the selection. If your filter is set to only show that filename, then a load, expand all, select all.files, copy, should lead to selecting only that file and copying it. You can preview this in the interface by setting the filter (copy/paste into the filters dropdown box), and then issue an Edit menu -> Expand All, Edit menu -> Select All Files. Does this leave you with just the selection of the file (or files for other scenarios) you wish to copy?
    Aaron P Scooter Software

  3. #3
    Join Date
    Jan 2014
    Posts
    9

    Default

    Aaron,
    Thanks for the quick reply. As expected, what you suggested worked. Here is my working script. I did not include the expand all command, as there may be files with the same name in other directories, and I want to be sure to only get the file at the path I'm providing.

    log verbose %3
    criteria binary
    filter %4
    load %1 %2
    select all.files
    copy left->right

    However this led me to discover something I wasn't expecting. I thought for sure I had already tried using a select command, but with undesirable results. And I was right... I was using the same script as above, but using select all (not select all.files), assuming that since I had already filtered down to a filename, the folders would not be selected. I suppose this is not the case. I retested my theory and sure enough, using just select all actually copies every file from every directory, even subdirectories (copied 114 items instead of 1), and really only seems to filter the files in the root directory. Is this a feature of some sort? If it is, I think this should be documented somewhere, as it seems somewhat confusing.

    Regardless, thank you for your help! My script is now working.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,788

    Default

    Hello,

    If the selection results in selecting the folder, the entire contents of the folder are copied (to match BC2 and Scripting backwards compatibility).

    The Expand command and filter command can be made to be more specific, to match on a specific path or file, if you want it to avoid matching on other files/folders.
    .\subfolder\file (with a leading .\) always starts in the base location.

    Please let us know if you have any questions.
    Aaron P Scooter Software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •