Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2018
    Posts
    13

    Default Copying file by script

    I'm still working on a FTP backup Applescript by sending
    Code:
    bcompare@ "my_script.txt"
    It works fine to SYNC mirror folders but I would like to know if it's possible copy only files.

    I don't understand how to use command like COPYTO
    Code:
    copyto [left|right|all] [path:(relative|base|none)] <path>
    with only one path (source or destination), as I need both source and destination path.

    Thank you for your help.

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

    Default

    Hello,

    The one path is the target (The "to" it will copy to). The immediately previous line should be a "select" line, and before that an "expand all".

    For example, something like this:
    load "c:\folder1" "c:\folder2"
    expand all
    select all.newer.files all.orphan.files
    copyto all path:base "c:\destination"

    I would recommend stepping through this in the graphical interface (load the Folder Compare, expand, use the display filters to limit the view, Expand All command, Select All Files command, right click and Copy To Folder command on the selection.
    Aaron P Scooter Software

  3. #3
    Join Date
    Oct 2018
    Posts
    13

    Default

    Thank you Aaron for you quick and detailed answer.
    If I well understand (my english is not very good), this will not fill my personal need. I was trying to copy a single local file to a distant folder without graphical UI.
    The goal was to drop a single file onto an Applescript droplet to copy it to my FTP folder, regardless it already exists in the destination folder, but I don't think it's possible.

    So it would be something like :
    Code:
    load "path_to_my_file" "my_distant_ftp_folder
    or
    Code:
    copy "path_to_my_file" "my_distant_ftp_folder
    Quote Originally Posted by Aaron View Post
    For example, something like this:
    load "c:\folder1" "c:\folder2"
    expand all
    select all.newer.files all.orphan.files
    copyto all path:base "c:\destination"

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

    Default

    Hello,

    For a specific file, you could set a filter to only that file's location. I would also recommend setting this in the graphical interface first:
    load your two folders
    set a file name filter to only the file you want to copy, and note the syntax used in the Filter toolbar: ".\folderto\filename.txt"

    In script, you can copy and paste the filter, adding quotes:
    filter ".\folderto\filename.txt"
    load "c:\folder1" "c:\folder2"
    expand all
    select all.files
    copyto all path:base "c:\destination"

    Once the script is working for a very specific file, you can broaden it with variables:
    bcompare.exe "@c:\bcscript.txt" "c:\folder1" "c:\folder2" ".\folderto\filename.txt" "c:\destinationfolder"

    where bcscript.txt is:
    filter "%3"
    load "%1" "%2"
    expand all
    select all.files
    copyto all path:base "%4"

    Please always intially test script against test files and folder locations. BC4 does not support UNDO, and does not preview before taking script actions.
    Aaron P Scooter Software

  5. #5
    Join Date
    Oct 2018
    Posts
    13

    Default

    Great!

    It works fine
    Thank you very much for your help, Aaron.

    I only have just little problem with option confirm:yes-to-all
    I added option confirm:yes-to-all as the last line of my text file (the one called by bcompare @) but I always have replacement confirmation dialogs when file already exists in the distant destination folder.

  6. #6
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    2,525

    Default

    option confirm:yes-to-all should be one of the first lines in your script. BC reads and runs each line as it comes to it, so if it's last it won't have any effect since everything is already done.
    ZoŽ P Scooter Software

  7. #7
    Join Date
    Oct 2018
    Posts
    13

    Default

    Ok, it works
    Thank you very much.

Posting Permissions

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