Portable Folders For Windows


descention

Recommended Posts

I couldn't find a good solution for defining shares for a portable drive and decided to write a script to help me out. The following AutoIt code allows me to define shares in "sync.conf.portable" with a share directory replacement of "%SD%" to the script directory. I placed this code with my BTSync.exe file, execute the script to launch BTSync, and can now have my share change drive letters from one PC to another.

...    "dir":"%SD%\\Share",...

%SD% will be replaced by the script directory and does not support '..' for going up a directory. Yet.

#include <OO_JSON.au3>$file = @ScriptDir & "\sync.conf"if FileExists($file & ".portable") Then   $json = FileRead($file & ".portable")   _OO_JSON_Init (  )   $object = _JS_obj_create($json)   $base = $object.objToString()   if @error Then	  ConsoleWrite("Error: " & @error & @crlf)   Endif   $dir = $object.shared_folders.item(0).dir   if StringInStr($dir,"%SD%", True) Then	  $object.shared_folders.item(0).dir = StringReplace($object.shared_folders.item(0).dir, "%SD%",@ScriptDir)   EndIf   FileDelete($file)   FileWrite($file, $object.objToString())   _OO_JSON_Quit (  )EndIfRun(@scriptDir & "\BTSync.exe /config sync.conf",@ScriptDir)

Forum Link: OO_JSON

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.