Page 1 of 1

Truncating file path

Posted: 03 Oct 2011 09:41
by airkemp
Hi There,

I am given a folder path through an input, it comes in as %1 and prints the following;

C:\Folder1\Folder2\Folder3\Folder4

How can i ommit the first 3 paths (including the drive letter), printing just;

Folder3\Folder4

Any help you be appriciated,

Many Thanks

Alex

Re: Truncating file path

Posted: 03 Oct 2011 10:04
by colargol

Code: Select all

for /f "tokens=3* delims=\" %%a in ("%~1") do (set trunc=%%b)
echo %trunc%


hope **consored** will correct if I'm wrong :)

Re: Truncating file path

Posted: 04 Oct 2011 06:47
by airkemp
Works a charm!

Thanks alot

Alex