| 1. |
Solve : Adding path to file name in file? |
|
Answer» Gudday all I am sure that teh problem is staring me in the face but I cannot see it. !full_path! not %full_path% Its probably time to call me stupid Code: [Select]rem *** Add file_path to each line of SPLfiles.txt to make complete path and file name for /f %%a in (SPLfiles.txt) do ( set file=%%a rem echo %%a set full_path=!file_path!%%a echo !full_path! echo !fullpath! >> SPLfiles-1.txt ) ST Your change worked a treat but now I want to put the amended variable full_path into a new file called SPLfiles-1.txt. So simple I thought using Code: [Select]echo !fullpath! >> SPLfiles-1.txt would do it But all I get is Quote ECHO is off.What has happened? I don't know about the differences between %%var, %var% and !var! etc: It is really quite mind-bending at the moment.The problem is your computer. It is not clever enough to know that when you typed !fullpath! you really meant !full_path!. Quote from: Tigers! on November 23, 2009, 04:43:19 PM C:\batch>cat xnewpath.bat rem *** Add full_path to each line of xsplfiles.txt to rem make complete path and file name Code: [Select]@echo off setlocal enabledelayedexpansion dir /b *.bat > xsplfiles.txt echo. > splfiles-1.txt set full_path=C:\batch\ echo full_path=!full_path! for /f "delims=" %%a in (xsplfiles.txt) do ( set full_path=!full_path!%%a echo !full_path! echo !full_path! >> SPLfiles-1.txt set full_path=C:\batch\ )C:\batch> OUTPUT: C:\batch>xnewpath.bat C:\batch>rem *** Add file_path to each line of xsplfiles.txt to rem make complete path and file name full_path=C:\batch\ C:\batch\2line.bat C:\batch\2pdfdos.bat C:\batch\A.bat C:\batch\anecho.bat C:\batch\ans.bat C:\batch\arctwoold.bat C:\batch\B.bat C:\batch\backdate.bat C:\batch\Batch1.bat C:\batch\batchname.bat C:\batch\batch_1.bat C:\batch\batch_2.bat C:\batch\batcopy.bat C:\batch\batexe.bat C:\batch\batfile.bat C:\batch\bc.bat C:\batch\bcalc.bat C:\batch\beep.bat C:\batch\best.bat C:\batch\bill0910.bat C:\batch\bill0911.bat C:\batch\bill72.bat C:\batch\billyo.bat C:\batch\brost.bat C:\batch\Bver.bat C:\batch\cal.bat . . . C:\batch> INPUT Data file: C:\batch>type xsplfiles.txt 2line.bat 2pdfdos.bat A.bat anecho.bat ans.bat arctwoold.bat B.bat backdate.bat Batch1.bat batchname.bat batch_1.bat batch_2.bat batcopy.bat batexe.bat batfile.bat bc.bat bcalc.bat beep.bat best.bat bill0910.bat bill0911.bat bill72.bat billyo.bat brost.bat Bver.bat cal.bat . . . C:\batch>Quote from: Tigers! on November 23, 2009, 04:43:19 PM Try the following code: rem *** Add full_path to each line of SPLfiles.txt to make complete path and file name Code: [Select]@echo off setlocal enabledelayedexpansion rem dir D:\Archives\E20_120_AU\ArchiveCreator\Errors\*.spl /b > SPLfiles.txt set full_path=D:\Archives\E20_120_AU\ArchiveCreator\Errors\ echo. > SPLfiles-1.txt for /f "delims=" %%a in (SPLfiles.txt) do ( set full_path=!full_path!%%a echo !full_path! echo !full_path! >> SPLfiles-1.txt set full_path=D:\Archives\E20_120_AU\ArchiveCreator\Errors\ ) Quote from: BillRich Try the following code: Er, no. Quote from: Salmon Trout on November 24, 2009, 04:20:55 AM Er, no. It worked. Look at the previous POST. The code speaks for its self. Do you always question success? « Last Edit: Today at 05:06:37 AM by MikeTaylor » Bill Richardson C:\>date /t Tue 11/24/2009 C:\>time The current time is: 6:20:49.67 Enter the new time: C:\>Quote from: Billrich Do you always question success? Quote from: Billrich
Quote from: Me
Quote from: Billrich
lol, and the cycle goes on.Billrich, my local time is GMT (Zulu). Billrich replicated the error made by Tigers!, namely the missing underscore, then after my reply he went back and edited his post to make it seem LIKE he hadn't. Such behaviour is infantile in the extreme, and justifies the epithet of "troll" which I and others have applied to him. Quote from: Salmon Trout on November 24, 2009, 05:17:25 AM Bill Richardson, my local time is GMT (Zulu). Name calling is infantile. I don't hide my name or my posts. I did make the edit from fullpath to full_path. I was not trying to hide anything. I also made several other edits. I could not test the Tiger code. I do not have Tiger's input data file, a D Drive nor the path Tiger refers to. The test code above with output is much the same. Have a great day. p.s. I did drop the billrich login. Mike Taylor is not my real name. Is Salmon Trout your real name? Hardly anyone uses their real name. What else should I not do? THANKS for your help and concern. Gents I have modified !fullpath! to !full_path! and the code works well. It is loaded onto the servers and is working. Thank you for your help. |
|