Command Line - Batch File Guru

Discussion in 'Software' started by foogoo, Sep 9, 2019.

  1. foogoo

    foogoo Major "foogoo" Geek

    I know we have one around here... Can you explain when you need to use the tilda ~ like "~1%" vs "1%"?
    I have a batch file that should be getting kicked off everytime a new file is discovered in a specifi folder (Directoy Monitor program). This was their code
    Execute: C:\MyScripts\MyCopyBatch.bat
    Parameters: %fullfile% %filename%
    The code for MyCopyBatch.bat would look like this
    copy /Y "~%1" "D:\Shared\tix\BGS\~%2"
    But it looks like the ~ is appending to the filename and making it error file cannot be found.
    I changed to
    copy /Y "%1" "D:\Mason\Group\Shared\scale-tix\BGS\
    No second parameter and it copies just fine.
     
  2. Eldon

    Eldon Major Geek Extraordinaire

    I'm no guru but you changed the batch file more than just removing the second parameter.
    It seems like the file path in the first batch file is wrong.

    In a batch file the tilde expands the given variable.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds