plz help me now! read and show text ?
Moderator: DosItHelp
plz help me now! read and show text ?
i have a text file : a.txt
C:\Users\SonyMan\Desktop\toolbox\dragdrop_apk_editor\smali_time.132306
i want read string "132306" and show it
thank!!!
C:\Users\SonyMan\Desktop\toolbox\dragdrop_apk_editor\smali_time.132306
i want read string "132306" and show it
thank!!!
Re: plz help me now! read and show text ?
Code: Select all
@echo off
for /f "delims=" %%F in (a.txt) do for /f "delims=." %%N in ("%%~xF") do @echo %%N
Re: plz help me now! read and show text ?
Code: Select all
@for /f %%i in ('"<a.txt set /p x=& call set /a %%x:*.=%%"') do @echo %%i
Re: plz help me now! read and show text ?
Just an FYI for the original poster.
For just one line the time difference is fairly trivial. Dave's code is still faster but not by much.
But if you wrap them in a FOR /L and make each set of code execute 10,000 times, Dave's code is considerably faster. We are talking by several minutes.
The CALL slows down Yury's code. Also you would not be able to use Yury's code if your input file had more than one line in your input file.
For just one line the time difference is fairly trivial. Dave's code is still faster but not by much.
But if you wrap them in a FOR /L and make each set of code execute 10,000 times, Dave's code is considerably faster. We are talking by several minutes.
The CALL slows down Yury's code. Also you would not be able to use Yury's code if your input file had more than one line in your input file.
Re: plz help me now! read and show text ?
This is all you need:
Code: Select all
@echo off
for /f "usebackq delims=" %%a in ("a.txt") do echo %%~xa
Re: plz help me now! read and show text ?
foxidrive wrote:This is all you need:Code: Select all
@echo off
for /f "usebackq delims=" %%a in ("a.txt") do echo %%~xa
Not quite That includes the unwanted dot from the extension. That is why I have an extra loop.
Re: plz help me now! read and show text ?
dbenham wrote:Not quite That includes the unwanted dot from the extension. That is why I have an extra loop.
yeah, good point.
Re: plz help me now! read and show text ?
One more way: .
Code: Select all
@for /f %%i in ('cmd /u /c type "a.txt"^| more^| findstr [0-9]') do @<nul set /p=%%i
Re: plz help me now! read and show text ?
Yury wrote:One more way:.Code: Select all
@for /f %%i in ('cmd /u /c type "a.txt"^| more^| findstr [0-9]') do @<nul set /p=%%i
This assumes numbers never appear anywhere else in the path - probably not a good assumption.
Re: plz help me now! read and show text ?
thank for all!!
this here folderpath if i want read and show folder name "smali_time.132306" how to do?
this here folderpath if i want read and show folder name "smali_time.132306" how to do?
Re: plz help me now! read and show text ?
Code: Select all
@for /f "usebackq delims=" %%i in ("a.txt") do @echo %%~nxi