ask for filepath if the file is new

April 7, 2009 at 04:20:44
Specs: Windows XP
Hi Everyone,

I have another problem. i have a filelist.txt and i have all the filenames that needs to be searched inside a certain directory. if i found a filename not on that certain directory, it will prompt me on where should i place that file.

example filelist.txt has:
file1.txt
file2.txt

i will search C:\temp
file2.txt is in C:\temp\temp1
however, file1.txt and it will prompt where should i place the file. ill give the path (say C:\temp\temp1\temp2) then it will create dir for me (if it doesnt exist) and copy the file.

so my main problem is.. how could i parse the filenames from my filelist.txt and begin search it on a certain directory.. and it would prompt me on where should i place the new file..


See More: ask for filepath if the file is new

Report •


#1
April 7, 2009 at 21:58:22
Hi Everyone,

I've figured out on how to do this. however, I'm having a problem on passing the value of the variable inside the text file. i also want to include the value of the variable i've assigned outside this if statement. kindly help. this is my code:

for /f "delims=" %%x in (filelist.log) do (
	
	echo %%x
	findstr /C:"%%x" result.txt> nul
	if errorlevel=1 (
		echo enter the filepath on where should place the new file: %%x
		echo filepath should be a relative path: e.g. /web/WEB-INF/classes/
		set /p %newPath%=
		echo %codebase%%newPath%%%x >> result.txt
	)
	set %newPath%=
)

note that i should also have a value for the variable %codebase% and i want to include that value to be passed inside result.txt

the output displays the value of the %codebase% and %%x but the %newPath% is empty

kindly help.


Report •

#2
April 7, 2009 at 23:22:17
Hi Everyone,

I had some minor mistakes from my post. and,at the same time, i was able to resolve it also.. just to share my working code.

for /f "delims=" %%x in (filelist.log) do (
	
	echo %%x
	findstr /C:"%%x" result.txt> nul
	if errorlevel=1 (
		echo enter the filepath on where should place the new file: %%x
		echo filepath should be a relative path: e.g. /web/WEB-INF/classes/
		set /p newPath=
		echo %codebase%!newPath!%%x >> result.txt
	)
	set newPath=
)


Report •

Related Solutions


Ask Question