Prev: Caught in an Endless Boot-up Loop
Next: Virtual McAfee?
From: Ronny on 17 May 2010 10:06 Suppose I have a variable FILE which contains the full path to a file. To store the name of the directory where this file is stored, I use in my batch file the following assignment: for %%F in ("%FILE%") do set DIR=%%~dpF This works, but %DIR% contains the directory name with a trailing backslash added. Is there an easy way to get the directory name WITHOUT the backslash? For instance, if FILE is \\share\c:\foo\bar\baz.txt, I would like DIR to contain \\share\c:\foo\bar and not \\share\c:\foo\bar\
From: Twayne on 18 May 2010 13:17 In news:0d88bf11-d9a4-4657-8468-8d1cbd6889a0(a)40g2000vbr.googlegroups.com, Ronny <ro.naldfi.scher(a)gmail.com> typed: > Suppose I have a variable FILE which contains the full path > to a file. To store the name of the directory where this > file is stored, I use in my batch file the following > assignment: > > for %%F in ("%FILE%") do set DIR=%%~dpF > > This works, but %DIR% contains the directory name with a > trailing backslash > added. Is there an easy way to get the directory name > WITHOUT the backslash? > > For instance, if FILE is \\share\c:\foo\bar\baz.txt, I > would like DIR to contain > \\share\c:\foo\bar and not \\share\c:\foo\bar\ Use Find to see if the last character is a back slash (or a forward flash, for that matter). If it's there, remove it by truncating. alt.msdos.batch.net has some real experts there. They're great for these kind of questions but be polite and professional. HTH, Twayne`
|
Pages: 1 Prev: Caught in an Endless Boot-up Loop Next: Virtual McAfee? |