Batch Read Text From a Child Directory [closed] - windows

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i plan on releasing a tool to back up gamesaves for a certian game but i am having problems with batch telling it to get its text. i get returned with Wput but i want it to say ftp://SPECIFIED_USER_IN TEXT FILE:
Not quite sure if this is possible but i looked around(UPLOAD represents wput.exe) UPLOAD isnt the issue. the issue is telling it where to go.
#echo off
set /p user=./server_information/user.txt
set /p pass=./server_information/pass.txt
set /p host=./server_information/host.txt
ser world=worldname.txt
cd UploadingHandler
upload ftp://%user%:%pass#%host%:21/%world% %world%
pause
any help? Thanks.
edit:
if you need better understanding here is a treemap:
ROOT
UploadingHandler
epload.exe
-
Server_Information
Host.txt
user.txt
pass.txt
-

The SET /P command reads input from the console unless you redirect the input to be from another device, e.g. from a file. This is done using the < symbol:
SET /P variable=prompt text < filename
The prompt text part is optional. So, to give you an example using one of your files:
set /p user=<./server_information/user.txt

Not sure if this is what you wanted either, but to read a file using batch you could do this:
for %%a in (myfile.txt) do print %%a
or:
for %%a in (myfile.txt) do :adef
:adef
print %%a

Related

Rename Multiple file on using .cmd or .bat [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have directory which contain no. of file like this
abac_273#jj.txt ,
hhh.78448#kkpp.txt ,
dgfhf#ytyt#llltyui.txt
I need to write batch script where I need to rename those file like this
jj.txt , kkpp.txt, llltyui.txt
In simple words, I need to find out # from end and return string after # as output.
Can you please help me out to solve this
for /f "tokens=1*delims=#" %%a in ('dir /b /a-d "*#*"') do echo(ren "%%a#%%b" "%%b"
should provide what you want - reduce each %% to % if you execute this from the prompt instead of as a batch line.
If it works correctly for you, change the echo(ren to ren to actually do the change - this code will simply report the proposed change to the screen.

Removing certain characters of a certain file [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to remove certain characters from multiple files which share the same extension. An example would be: filename = 01songname.mp3 to songname.mp3, but doing that command to all the mp3 files in the directory, not renaming to one name but removing the numbering.
Based on your existing examples this may work for you.
#echo off
FOR %%M IN (*.mp3) DO (
FOR /F "tokens=* delims=0123456789" %%G IN ("%%~M") DO ECHO RENAME "%%~M" "%%~G"
)
pause
Remove the word ECHO before the word RENAME if you feel the output on the screen looks correct.

Creating year,month,date folder structure based on filename [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have some files in a some unix server. When i copy to windows, based on filename , the file has to be copied into corresponding year,corresponding month and corresponding date folders. Sample filename : 20120201.117_visual_sciences_web_feed.out.gz.
Folder structure to be created based on first part of filename, in this case : 20120201(YYYY,MM,DD) . In above example ,filename should be copied into 2012 -> 02-> 01 folder.Folders should be created if not created Honestly i am not getting how this can be implemented, please suggest.
This should do the trick for you -
#echo off
set filename=20120201.117_visual_sciences_web_feed.out.gz
set filepath=PATH\TO\%filename%
REM get the date from the file name
for /f "delims=." %%A in ("%filename%") do set fdate=%%A
REM Y=YEAR; M=MONTH; D=DAY
set Y=%fdate:~0,4%
set M=%fdate:~4,2%
set D=%fdate:~6,2%
REM echo %Y% %M% %D%
REM check to see if directories exist
if not exist \%Y% mkdir %Y%
if not exist \%Y%\%M% mkdir %Y%\%M%
if not exist \%Y%\%M%\%D% mkdir %Y%\%M%\%D%
REM copy the file to the newly created destination folder
copy %filepath% %Y%\%M%\%D%\%filename%
pause
I hope you're able to implement this into your script easily enough. As pointed out; if you added some examples from your script - I would be able to help more.

FOR statement to parse datetime stamp in file names [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
How will I accomplish the following in a FOR statement?
I have files in a windows PC directory that I want to identify by all or part of a datetime stamp that is part of the files name, ie-
CLIENT CODE / ID DATETIME STAMP
0000090000010009.CLIENTNAME.20121212140022.txt
0001090000010009.CLIENTNAME.20130916110025.txt
0001090000010009.CLIENTNAME.20130908150022.txt
I do not have to open/read the file. I just need to identify files in a particular date time range to either MOVE, DELETE or COPY them.
for /f "tokens=1-4delims=." %%a in ('dir /b /a-d "*.clientname.*.*"') do (
set "dts=%%c"
setlocal enabledelayedexpansion
set "yyyy=!dts:~0,4!"
set "mm=!dts:~4,2!"
set "dd=!dts:~6,2!"
set "hh=!dts:~8,2!"
set "min=!dts:~10,2!"
set "sec=!dts:~12,2!"
echo File: %%a.%%b.%%c.%%d date/time: !dd!/!mm!/!yyyy! -- !hh!:!min!:!sec!
endlocal
)
You can use the dir command with wildcard. So say you want the file 0000090000010009.CLIENTNAME.20121212140022.txt you can do:
dir *20121212140022*
If you want to put it in a loop then for /F will do the trick:
for /F %x in ('dir *20121212140022* /b /a-d ') do del %x

Findstr -- exclude a file type -- search only ascii [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to run a FINDSTR dos command in a way beyond what it is easily found in "findstr /?". How would I run findstr so that it only searches ascii files. (I am not sure if that is possible. My gut feeling is that it is not possible) Additionally, how would I run this command line so that it would exclude some file times. For example, what if I wanted to exclude .psd files
What is wrong with the /P option that is described in the help?
/P Skip files with non-printable characters.
It worked for me.
To take further control of which files are searched, simply iterate the files with a for loop and add whatever logic you need. To skip .psd files and also skip binary files:
for /f "eol=: delims=" %%F in ('dir /a-d /b^|findstr /live ".psd"') do findstr /p "search" "%%F"
Use a single percent instead of double percents if run from the command line.

Resources