#241 UPDATE on Ability to Change Drive Letter

open
nobody
None
5
2012-12-11
2012-12-11
Norm
No

In my previous post, I added a VBS script for locating a specific drive. I've updated the script for use with DirSyncPro. The script will automatically locate the desired removable drive (destination drive) and then run DirSyncPro so that the specified Profile file. To use the script, you must place a TXT file on the destination drive that is unique to the Profile/Destination. The script then search all drives looking for the TXT file. When it finds it, it changes directory (CD) to that drive. Then in the Profile for the destination, you DO NOT specify the destination drive letter in the B destination location. DirSyncPro will automatically take the current location as the location for the sync'ing to occur.

In the script below, I'm sync'ing my iTunes folders to a portable drive. Since I don't know the drive letter at the time, I've placed a file (I use the same base name as the name of the script and the Profile (.dcs) file, specifically 'AlliTunes'.TXT on the portable drive. The script will locate that file and then change the default directory (via CD) to that drive and then execute DirSyncPro. the .DSC file being use is setup normally with the exception that the destination location specified in B doesn't have a drive letter. The.DSC file is shown below the VBS script.

================================== .VBS Script ===============================================

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
Set objEnv = objShell.Environment("PROCESS")
For Each objDrive in objFSO.Drives
If objDrive.IsReady Then
If objFSO.FileExists(objDrive.DriveLetter & ":\AlliTunes.txt") Then
drvPath = objDrive.Driveletter & ":\"
objShell.CurrentDirectory = drvPath
objShell.Run "C:\Progra~2\DirSyn~1\DirSyn~1.exe /sync /nogui /quit C:\Progra~2\DirSyn~1\SYNC__AlliTunes.dsc"
End If
End If
Next

================================== .DSC Profile ===============================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dirsyncpro [
<!ELEMENT dirsyncpro (job*)>
<!ATTLIST dirsyncpro logfile CDATA ''>

<!ELEMENT job (schedule*)>
<!ELEMENT job (filter*)>
<!ATTLIST job name CDATA #REQUIRED>
<!ATTLIST job enabled (true|false) 'true'>
<!ATTLIST job src CDATA #REQUIRED>
<!ATTLIST job dst CDATA #REQUIRED>
<!ATTLIST job syncMode CDATA #REQUIRED>
<!ATTLIST job recursive (true|false) 'false'>
<!ATTLIST job verify (true|false) 'false'>
<!ATTLIST job logfile CDATA ''>
<!ATTLIST job copyAll (true|false) 'false'>
<!ATTLIST job copyLarger (true|false) 'false'>
<!ATTLIST job copyModified (true|false) 'false'>
<!ATTLIST job copyLargerAndModified (true|false) 'false'>
<!ATTLIST job copyNew (true|false) 'false'>
<!ATTLIST job delFiles (true|false) 'false'>
<!ATTLIST job delDirs (true|false) 'false'>
<!ATTLIST job delExcludedFilesA (true|false) 'false'>
<!ATTLIST job delExcludedDirsA (true|false) 'false'>
<!ATTLIST job delExcludedFilesB (true|false) 'false'>
<!ATTLIST job delExcludedDirsB (true|false) 'false'>
<!ATTLIST job syncConflictResolutionMode CDATA ''>
<!ATTLIST job skiplinks (true|false) 'false'>
<!ATTLIST job granularity CDATA '0'>
<!ATTLIST job timestampWriteBack (true|false) 'false'>
<!ATTLIST job backups CDATA ''>
<!ATTLIST job backupInline (true|false) 'false'>
<!ATTLIST job backupDir CDATA ''>

<!ELEMENT schedule EMPTY>
<!ATTLIST schedule type CDATA #REQUIRED>
<!ATTLIST schedule timeFrameFrom CDATA '01-01-1970 01:00'>
<!ATTLIST schedule timeFrameTo CDATA '01-01-1970 01:00'>
<!ATTLIST schedule interval CDATA '1'>
<!ATTLIST schedule time CDATA '01:00'>
<!ATTLIST schedule date CDATA '01-01-1970 01:00'>
<!ATTLIST schedule day CDATA '1'>
<!ATTLIST schedule monday (true|false) 'true'>
<!ATTLIST schedule tuesday (true|false) 'false'>
<!ATTLIST schedule wednesday (true|false) 'false'>
<!ATTLIST schedule thursday (true|false) 'false'>
<!ATTLIST schedule friday (true|false) 'false'>
<!ATTLIST schedule saturday (true|false) 'false'>
<!ATTLIST schedule sunday (true|false) 'false'>
<!ATTLIST schedule january (true|false) 'true'>
<!ATTLIST schedule february (true|false) 'false'>
<!ATTLIST schedule march (true|false) 'false'>
<!ATTLIST schedule april (true|false) 'false'>
<!ATTLIST schedule may (true|false) 'false'>
<!ATTLIST schedule june (true|false) 'false'>
<!ATTLIST schedule july (true|false) 'false'>
<!ATTLIST schedule august (true|false) 'false'>
<!ATTLIST schedule september (true|false) 'false'>
<!ATTLIST schedule october (true|false) 'false'>
<!ATTLIST schedule november (true|false) 'false'>
<!ATTLIST schedule december (true|false) 'false'>
<!ELEMENT filter EMPTY>
<!ATTLIST filter type CDATA #REQUIRED>
<!ATTLIST filter action CDATA #REQUIRED>
<!ATTLIST filter date CDATA ''>
<!ATTLIST filter dateType CDATA ''>
<!ATTLIST filter readonly (true|false) 'true'>
<!ATTLIST filter hidden (true|false) 'true'>
<!ATTLIST filter system (true|false) 'true'>
<!ATTLIST filter archive (true|false) 'true'>
<!ATTLIST filter owner CDATA ''>
<!ATTLIST filter group CDATA ''>
<!ATTLIST filter permissionValue CDATA ''>
<!ATTLIST filter fileSizeValue CDATA ''>
<!ATTLIST filter fileSizeType CDATA ''>
<!ATTLIST filter path CDATA ''>
<!ATTLIST filter pattern CDATA ''>
<!ATTLIST filter patternType CDATA ''>
]>
<dirsyncpro logfile="">
<meta program="DirSync Pro 1.45" os="Windows 7-6.1-x86" java="1.7.0_07-Oracle Corporation"/>
<job name="Backup iTunes C files to TunesBckUp1" enabled="true" src="C:\Users\Owner\Music\iTunes" dst="\iTunes Backup\iTunes Library" syncMode="ABCustom" recursive="true" verify="true" logfile="" copyAll="false" copyLarger="false" copyLargerAndModified="false" copyModified="true" copyNew="true" delFiles="true" delDirs="true" delExcludedFilesA="false" delExcludedDirsA="false" delExcludedFilesB="false" delExcludedDirsB="false" syncConflictResolutionMode="WarnUser" backups="0" backupInline="true" backupDir="" timestampWriteBack="false" ignoreDaylightSavingGarnularity="false" syncDirTimeStamp="false" granularity='0' skiplinks="true" preserveDOSAttributes="false" preservePOSIXFilePermissions="false" preservePOSIXFileOwnership="false">
<filter type="ByPattern" action="Include" patternType="File" pattern="*"/>
<filter type="ByPattern" action="Include" patternType="Directory" pattern="*"/>
</job>
<job name="Backup iTunes F files to TunesBckUp1" enabled="true" src="F:\My Documents\My Music" dst="\iTunes Backup\iTunes Videos" syncMode="ABCustom" recursive="true" verify="true" logfile="" copyAll="false" copyLarger="false" copyLargerAndModified="false" copyModified="true" copyNew="true" delFiles="true" delDirs="true" delExcludedFilesA="false" delExcludedDirsA="false" delExcludedFilesB="false" delExcludedDirsB="false" syncConflictResolutionMode="WarnUser" backups="0" backupInline="true" backupDir="" timestampWriteBack="false" ignoreDaylightSavingGarnularity="false" syncDirTimeStamp="false" granularity='0' skiplinks="true" preserveDOSAttributes="false" preservePOSIXFilePermissions="false" preservePOSIXFileOwnership="false">
<filter type="ByPattern" action="Include" patternType="File" pattern="*"/>
<filter type="ByPattern" action="Include" patternType="Directory" pattern="*"/>
</job>
</dirsyncpro>

=====================================================================================

I hope everyone finds this information & code useful. I believe that DirSyncPro is THE BEST application available in this space and
if you find this stuff I posted helpful, please feel free to donate some $$$ to their efforts.

Thanks,
Norm

Discussion