home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,993 of 68,980   
   Zaidy036 to icaro   
   Re: split a variable that contains a pat   
   01 Jan 23 15:32:03   
   
   From: Zaidy036@air.isp.spam   
      
   On 1/1/2023 2:41 PM, icaro wrote:   
   > On Sun, 1 Jan 2023 08:28:37 +0100, "R.Wieser"    
   > wrote:   
   >   
   > Hi Rudy,   
   > you're right. I'm trying to make a backup script to sync some folders   
   > on my Windows PC via SSH to another Windows machine. Because Windows   
   > doesn't have a rsync client I've tried to keep aligned the directories   
   > with WinSCP commandline.   
   > Unfortunately WinSCP can't create nested paths using a single command   
   > like mkdir /c:/bk/dir1/dir2/dir3 but needs to proceed dir by dir (it   
   > does not have -p switch to make parent directories). This is why I   
   > need the weird output.   
   >   
   > Eventually I found a way to customize a script taken from   
   > StackOverflow   
   >   
   > @echo off   
   > setlocal enabledelayedexpansion   
   > set "out="   
   > set s=C:\Some\thing\not\so\useful   
   > set t=%s%   
   > :loop   
   > for /f "tokens=1* delims=\" %%a in ("%t%") do (   
   > 	set out=!out!/%%a   
   > 	if "!out:~-1!" NEQ ":" echo out = "!out!"   
   > 	set t=%%b   
   > 	)   
   > if defined t goto :loop   
   > setlocal disabledelayedexpansion   
   >   
   > This is the output:   
   > out = "/C:/Some"   
   > out = "/C:/Some/thing"   
   > out = "/C:/Some/thing/not"   
   > out = "/C:/Some/thing/not/so"   
   > out = "/C:/Some/thing/not/so/useful"   
   >   
   > Regards,   
   > icaro   
   >   
   >> "icaro"  wrote in message   
   >> news:5bk1rh95bmkml250qnuaias1pv24l11sc0@4ax.com...   
   >>   
   >>> Could you please help me?   
   >>   
   >> First question : What did you try yourself ?   Please include it in your   
   >> question.  Who knows, maybe just a small adjustment is needed to get it to   
   >> work ...   
   >>   
   >> Second question : are you sure you need all those paths ?  Maybe if you   
   >> describe what you need it for* there is an easier solution available   
   >>   
   >> * find the path to a specific file perhaps ?  (see "for /?")   
   >>   
   >> Remark : I assume its *not* a homework assignment ...   
   >>   
   >> A possible way to a solution to what you asked :   
   >>   
   >> https://stackoverflow.com/questions/26537949/how-to-split-var   
   ables-in-batch-files   
   >>   
   >> Remark #2 : Do realize that the batch environment is rather finickey in   
   >> regard to string handling.  Throwing random strings at any batch solution   
   >> will likely break sooner or later.   
   >>   
   >> Regards,   
   >> Rudy Wieser   
   >>   
   I have never used WinSCP but RoboCopy will do what you want with one   
   statement copying C:/Some   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca