Windows aspera-prepost.bat changing slashes in the %FILE% variable


When using the %FILE% environment variable in your pre-post processing scripts on Windows, the variable will use Unix style slashes. For example, the variable would contain something like:


Such paths do not work for operating system command file operations, so you will need to change the slashes to the Windows format in your scripts.


To change the variable to use Windows style slashes, include the following command in your processing script before the %FILE% variable is used:

set FILE=%FILE:/=\%

The variable FILE now will have the proper slashes.

Below is an example script:

REM %FILE% is C:/DATA/myfile.txt
echo %FILE%
REM -------------------
REM Output will be C:/DATA/myfile.txt
REM -------------------
REM The following will subsitute the /'s to \'s
set FILE=%FILE:/=\%
REM -------------------
REM show the FILE variable again
echo %FILE%
REM -------------------
REM Now the output will be C:\DATA\myfile.txt

Now you can reference %FILE% which will have the proper Windows slashes for file operations.

Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk