Jump to content

User:Melab-1/Batch File Question

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Batch File: File Tree

Does this batch file properly store the computers file tree into a txt file in my documents folder (C:\Users\'User'\Documents)

@echo off
set /p filetree=tree /F C:\
echo %filetree% > Filetree.txt
echo File tree has been made
pause

--Melab±1 00:26, 14 November 2008 (UTC)

Why don't you tell us? What results do you get when you run it? -- Tcncv (talk) 01:42, 14 November 2008 (UTC)

The syntax is wrong. Change it to this:

@echo off
set filetree=tree /F C:\
%filetree% > Filetree.txt
echo File tree has been made
pause

Set /p is for a prompt. You don't need to set a variable either -- I'm not sure why you did that. I'd just do it like this:

@echo off
tree /F C:\ > Filetree.txt
echo File tree has been made
pause

That's assuming you want to include file names in the tree (hence the /F). It's also assuming that you're in your documents folder when you run the batch file. If you aren't, you'd need to change > Filetree.txt to > C:\Users\user\documents\Filetree.txt. Good luck with your assignment ;).--Areateeth34 (talk) 02:16, 14 November 2008 (UTC)