Move files to a particular folder automatically

Asked

Viewed 4,854 times

0

I have a backup routine in SQL that automatically generates backup of databases in this folder: D:\Backup\Backup_SQL\Databases

I created a bat (forfiles) that compresses these backup files and transfers them to another folder. The script is running correctly. Now I want to change the destination folder of the compressed files but this folder contains space in its name: Box Files. This folder is from an application that plays its own content in the cloud. As the folder contains space in the name, it is giving error in the execution of the script. It is possible to make the bat recognize this folder with space?

Note. Cannot change the name of this folder as it is the default Box application.

Bat script used:

REM Path to WinRAR executable in Program Files
 set path="C:\Program Files (x86)\WinRAR\";%path%

set data=%DATE%
 set CURRDATE=%DATE:/=-%
 set dia=%data:~-0,4%

set horario=%time%
 set CURRTIME=%time:/=-%
 set hora=%horario:~-0,2%

rar a F:\Teste Teste\Databases_%CURRDATE%_%HORA%.rar D:\Backup\Backup_SQL\Databases

pause

@ECHO ON

-------

Resultado da execução do bat:


 D:\Backup\Script de backup>REM Path to WinRAR executable in Program Files

D:\Backup\Script de backup>set path="C:\Program Files (x86)\WinRAR\";C:\Windows\
 system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShe
 ll\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program
 Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server
 \100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShel
 l\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Prog
 ram Files (x86)\Java\jdk1.6.0_26/bin;C:\Program Files (x86)\Common Files\MicroSt
 rategy;C:\Program Files (x86)\MicroStrategy\Intelligence Server;C:\Program Files
  (x86)\Common Files\MicroStrategy\JRE\170_51\Win32\bin\client;

D:\Backup\Script de backup>set data=08/06/2015
D:\Backup\Script de backup>set CURRDATE=08-06-2015
D:\Backup\Script de backup>set dia=08/0
D:\Backup\Script de backup>set horario=10:34:00,10
D:\Backup\Script de backup>set CURRTIME=10:34:00,10
D:\Backup\Script de backup>set hora=10
D:\Backup\Script de backup>rar a F:\Teste Teste\Databases_08-06-2015_10.rar F:\B
 KP_Teste\My_Box_Files\Databases

RAR 4.01   Copyright (c) 1993-2011 Alexander Roshal   28 May 2011
 Shareware version         Type RAR -? for help

Evaluation copy. Please register.

Cannot open Teste\Databases_08-06-2015_10.rar
 O sistema não pode encontrar o caminho especificado.
 Creating archive F:\Teste.rar

Adding    F:\BKP_Teste\My_Box_Files\Databases\VETORHPROD\Texto.txt    OK
 Adding    F:\BKP_Teste\My_Box_Files\Databases\VETORHPROD              OK
 Adding    F:\BKP_Teste\My_Box_Files\Databases                         OK
 Done

D:\Backup\Script de backup>pause



Pressione qualquer tecla para continuar. . .

Thanks in advance.

Daniel.

  • 2

    Tried to put the path between double quotes? rar a "F:\Teste Teste\Databases_%CURRDATE%_%HORA%.rar" D:\Backup\Backup_SQL\Databases

  • That way I had not tried yet, but I managed to solve this by putting double quotes between the spaces. It looks like this: rar a F: Teste" "Teste Databases_%CURRDATE%_%HORA%. rar D: Backup Backup_sql Databases. Thanks for the help Eduardo Silva

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.