|
Answer» Hi everyone, I want to create a batch file to automatically copy the FOLLOWING folder to my flash drive.
Folder to copy = Thunderbird OS=Windows 7 C:\Users\WindowsUserName\AppData\ Roaming\Thunderbird Copy to...... Where ever the batch file on flash drive is... for example if my batch file is in G:\backup i want the folder "Thunderbird" to be copied in G:\backup folder. NOTE: the drivel letter can change according to attached devices. it can be H:\backup or J:\backup. i want the batch file to copy "Thunderbird" folder regardless of drive letter of flash drive. Just copy the folder where the batch file resides.
I want to the same batch file to work on windows XP also (if possible). the location of the folder "Thunderbird" on windows XP is C:\Documents and Settings\WindowsUserName\APPLICATION Data\Thunderbird
NOTE: WindowsUserName should be the name of user currently logged on. I want it to work in any account without worrying about user name I have tried to read tutorials of creating batch files but could not create my batch file. Please helpIs this for Windows 7? I http://www.informationweek.com/byte/personal-tech/desktop-operating-systems/how-to-automate-synctoy-jobs-in-windows/231001020 SyncToy is available from Microsoft. http://www.microsoft.com/en-us/download/details.aspx?id=15155 There are already many attempts to automate o this kind of thing. Some free. Others you buy for absurd prices. Why do it in batch? Because of security issues, it has to be stated by somebody with administrative permissions. Getting around that can be a chore. Otherwise, your would just run SyncToy as administrator. Once you have created a profile, you just plug in the flash drive and start up SyncToy with the profile. Is this what you want? I gather that you are CLICKING a BAT file on the flash drive itself. This will backup the folder to \tb_backup in the root of the flash drive, for the current user.
Untested - and you may need to right click and elevate permissions.
Code: [Select]@echo off rd /s /q "\TB_backup" 2>nul
if exist "C:\Users\%username%\AppData\Roaming\Thunderbird\" ( xcopy "C:\Users\%username%\AppData\Roaming\Thunderbird\*.*" "\TB_backup\" /s/h/e/k/f/c )
if exist "C:\Documents and Settings\%username%\Application Data\Thunderbird\" ( xcopy "C:\Documents and Settings\%username%\Application Data\Thunderbird\*.*" "\TB_backup\" /s/h/e/k/f/c ) pause Thanks to both of you. I have downloaded SyncToy and i will test the code also. I will post my feedback tomorrow after testing. Thanks a lot guysIt'll only work in batch if the destination drive...the flash drive...has a fixed drive letter... If you are moving it from to PC to PC as stated that may change and the batch file won't run properly...My effort above doesn't RELY on the drive letter - it uses the drive that the batch file is located on, which is the requirement I think from reading the posts.Thanks everybody, especially foxidrive Following is the code which worked for me - perfectly so far
set backupcmd=xcopy /s /c /d /e /h /i /r /y %backupcmd% "%AppData%\Thunderbird" "%CD%\Thunderbird"
It automatically copies Thunderbird folder from AppData and creates a folder named Thunderbird in the same directory where the batch file resides. The same code works on Win7, Win8, and WinXP. It does not matter which drive letter is assigned to my flash drive where the batch file resides.
Thanks to all of you
|