0

I have this var (source) which looks like this:

\\xxxxx\xxxx\xxx\Companies\test\in\Th FIle Test - Copy - Copy.mp4

I would like to remove everything before "\" character. So it would look like this:

Th FIle Test - Copy - Copy.mp4 

I looked at the trim function but not joy. I am using Batch, so I have a bat file.

Arthor
  • 666
  • 2
  • 13
  • 40

2 Answers2

1

I believe you can just use regular expressions. I'm unsure of the exact syntax for whatever program you're using, but the regex to search and replace should be relatively easy.

Replace .*\\ with '' (nothing)

https://regex101.com/r/hQ4hB9/1 <-- you can play around with this. Good website for testing regular expressions.

flamewheel
  • 121
  • 3
  • 11
0

The easiest way to get the leaf of the path is by using enhanced for variable references.

set "var=\\xxxxx\xxxx\xxx\Companies\test\in\Th FIle Test - Copy - Copy.mp4"
for %%I in ("%var%") do set "filename=%%~nxI"
echo %filename%

See the last couple of pages of help for in a console window for more information.

rojo
  • 24,000
  • 5
  • 55
  • 101