Batch Script to print file path, file name (including extension) and FULL length in character?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Batch Script to print file path, file name (including extension) and FULL length in character?

#1 Post by SIMMS7400 » 15 May 2017 09:19

Hi Folks -

Does anyone have a batch script can be run over a specific directory that prints the following:

1. File path (including drive)
2. File name (including extension)
3. TOTAL length

ONLY if the total length is OVER 218 characters?

Thanks!

Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

Re: Batch Script to print file path, file name (including extension) and FULL length in character?

#2 Post by Hackoo » 15 May 2017 09:55

SIMMS7400 wrote:Hi Folks -
Does anyone have a batch script can be run over a specific directory that prints the following:
1. File path (including drive)
2. File name (including extension)
3. TOTAL length
ONLY if the total length is OVER 218 characters?
Thanks!

Hi :)
So the condition is only if the total length is OVER 218 characters, we echo :
1 - The File Path
2 - The File Name
:?:
EDIT
Try this script :

Code: Select all

@echo off
set "Log=Test.txt"
If exist %Log% Del %Log%
setlocal enabledelayedexpansion
for /F "tokens=1 delims=" %%i in ('dir /o:-n /b /s') do (
    set FilePath=%%i
    set FileName=%%~nxi
    set part=!FilePath:~0,218!
    if !FilePath! GTR !part! (
      (
         echo !FileName!
         echo !FilePath!
         echo =========================
      )>>%Log%   
   )   
)
start "" %Log%

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Batch Script to print file path, file name (including extension) and FULL length in character?

#3 Post by SIMMS7400 » 16 May 2017 01:26

Thank you, Hack! Works like a charm!! :lol:

Post Reply