# Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

# Topic review

fiyapondat
Thanks for your help, I had to correct some spaces in the path but it works now. Just need to tweak it to be more specific. It's pulling more files than I want.
fiyapondat
The reason I removed "exit" is because it reports back that it's not recognized as an internal or external command. I definitely messed up with the spaces, I've been added and removing lines from it throughout testing. The error that I'm working through with everything corrected is:

Too many parameters for command synchronize
martin

## Re: Synchronize batch file for changing file name

You have spaces after the ^ at the open line. And you do not have spaces at the front of the synchronize line. And you are missing exit command. And you still have the quotes wrong.
Please read the article, I've posted above already:
https://winscp.net/eng/docs/faq_batch_file

@echo off "C:\Program Files (x86)\WinSCP\WinSCP.com" ^  /log="C:\log\WinSCP.log" /ini=nul ^  /command ^    "open sftp://blah :blah blah@files.blackbaudhosting.com/ -hostkey=""blah blah blah="" -rawsettings CacheDirectories=0 CacheDirectoryChanges=0" ^        "synchronize -filemask=17087dm*1_compressed.bak local ""E:\ProgramFiles\MicrosoftSQLServer\MSSQL13.MSSQLSERVER2016\MSSQL\Backup"" ""/production/17087/backup/""" ^    "exit" set WINSCP_RESULT=%ERRORLEVEL%if %WINSCP_RESULT% equ 0 (  echo Success) else (  echo Error) pauseexit /b %WINSCP_RESULT%
fiyapondat

## Re: Synchronize batch file for changing file name

Noticed that I didn't even have the freaking right path for the log file and that caused the error. So now it opens a session and just sits there, doesn't run the next line. Code below

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\log\WinSCP.log" /ini=nul ^
/command ^
"open sftp://blah :blah blah@files.blackbaudhosting.com/ -hostkey=""blah blah blah="" -rawsettings CacheDirectories=0 CacheDirectoryChanges=0" ^
"synchronize -filemask=17087dm*1_compressed.bak local "E:\ProgramFiles\MicrosoftSQLServer\MSSQL13.MSSQLSERVER2016\MSSQL\Backup" "/production/17087/backup/" ^

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

pause
exit /b %WINSCP_RESULT%
martin

## Re: Synchronize batch file for changing file name

That's wrong. Show us your full command-line with my version of the command and a session log file for that.
fiyapondat

## Re: Synchronize batch file for changing file name

I used the double quotes and got some syntax errors so I removed them and removed the spaces. Now I'm back to the error "the filename, directory name, or volume syntax is incorrect. This is the line I have now.

"synchronize -filemask=17087dm????1_compressed.bak local "E:\ProgramFiles\MicrosoftSQLServer\MSSQL13.MSSQLSERVER2016\MSSQL\Backup" "/production/17087/backup/" ^
martin

## Re: Synchronize batch file for changing file name

If there are spaces in the paths (like in your original "Program Files", not in your blah example), then it must be:
  "synchronize -filemask=17087dm????1_compressed.bak local ""E:\blah\blah\blah"" ""/blah/blah/blah""" ^

See
https://winscp.net/eng/docs/commandline#syntax
https://winscp.net/eng/docs/faq_batch_file
fiyapondat

## Re: Synchronize batch file for changing file name

Thank you, that's exactly what I was looking for but the code seems to be wrong somewhere. It gave me the error "is not recognized as an internal or external command. so I added the quotes to fix it and now it says the 'the filename, directory name or volume label syntax is incorrect. So I got more specific with the logic. This is where I am right now

"synchronize -filemask=17087dm????1_compressed.bak local E:\blah\blah\blah" "/blah/blah/blah" ^

I've also tried
"synchronize -filemask=17087dm*1_compressed.bak local E:\blah\blah\blah" "/blah/blah/blah"
local and got the same error:

the filename, directory name, or volume label syntax is incorrect. any ideas?
martin

## Re: Synchronize batch file for changing file name

Are you looking for the -filemask switch?
https://winscp.net/eng/docs/scriptcommand_synchronize#filemask

  "synchronize -filemask=*.txt local E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER2016\MSSQL\Backup /production/90872/backup/" ^
fiyapondat

## Synchronize batch file for changing file name

I'm trying to use a batch file to synchronize folders. The files I need name changes daily and I'm looking for a way to do using a batch. I have the file written up but can't find the command to grab the files. When i use the sync command in WinSCP I can filter to the specific files using *.file type. does anyone know if this can be accomplished in a batch or do I have to user powershell or something else? I know i can set it to grab the entire directory but I want to know if there is a way to say "only grab files with this extension.

Here is what I have so far:

@echo off "C:\Program Files (x86)\WinSCP\WinSCP.com" ^  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^  /command ^    "open sftp://unknkown:VFLx98u3g@files.insighthosting.com/ -hostkey=""ssh-rsa 1024 c36bXCOIuJJlXQcAxy3DLz+UYidT6Ylhfjdk4syUk="" -rawsettings CacheDirectories=0 CacheDirectoryChanges=0" ^    "synchronize local E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER2016\MSSQL\Backup /production/90872/backup/" ^ "exit"  set WINSCP_RESULT=%ERRORLEVEL%if %WINSCP_RESULT% equ 0 (  echo Success) else (  echo Error) pauseexit /b %WINSCP_RESULT%