Tech Support Guy banner
Status
Not open for further replies.
1 - 5 of 5 Posts

·
Registered
Joined
·
5 Posts
Discussion Starter · #1 ·
hi i need help with this-

Create a batch file that will create a new folder called C:\batch\copies, only if there are still arguments listed in the command, copy the argument into the new folder, then display a wide directory listing of the C:\batch\copies folder and append this to a file called listing.txt in the C:\copies folder. Repeat this until there are no more arguments in the command. When there are no more arguments, the batch file should only exit the file only, not the command windows.

im told i'll need 1 IF, 2 GOTO's , 2 LABELS, 1 SHIFT commands and to have a look at C:\copies\listing.txt to confirm directory listings were added

youll probably laugh at this but heres my attempt-

:eek:

:again
cd c:\batch & md copies
set todir=%1
shift
if "%1"=="" goto end
copy %1 %todir% | dir/w >> C:\copies\listing.txt
goto again
:end
pause


so question is how the hell do i do this question, ive spent heaps of time on this to no avail.

thanks again for reading.
 

·
Registered
Joined
·
5 Posts
Discussion Starter · #3 ·
hi dtech10 here all the info ive got.

Batch File 4 - Putting it all together

Create a batch file that will create a new folder called C:\batch\copies, only if there are still arguments listed in the command, copy the argument into the new folder, then display a wide directory listing of the C:\batch\copies folder and append this to a file called listing.txt in the C:\copies folder. Repeat this until there are no more arguments in the command. When there are no more arguments, the batch file should exit the file only, not the command window.

HINT: You will need 1 x IF, 2 x GOTO, 2 x LABEL'S, 1 x SHIFT and use argument substitution

HINT: Have a look at the file C:\copies\listing.txt to confirm the directory listings have been added

The command you will run will be something like: filename chris1.txt chris2.txt chris3.txt

odd thing is i was told at the start of this i was told to make 3 files called chris1.txt , chris2.txt and chris3.txt in the C:\batch directory. maybe the question relates to that somehow although the question doesn't seem to make sense if it does well not to me.
 

·
Registered
Joined
·
53 Posts
Hi

Looks likr homework to me, your code makes out that the first argument is a
directory (Folder) why.
I'm assuming that the files to be copied are in the directory that this
batch file is in and directory c:\Copies already exists.
Try something like this.

@echo off
if "%1"=="" goto Quit
if not exist g:\Batch\Copies md g:\Batch\Copies
:Again
echo %1
copy %1 g:\Batch\Copies
shift
if not "%1%"=="" goto Again
dir /w g:\Batch\Copies >> g:\Copies\Listing.txt
cls
type g:\Copies\Listing.txt
pause
:Quit
exit /b
 

·
Registered
Joined
·
9,026 Posts
Code:
@Echo off
If NOT EXIST c:\batch\copies md c:\batch\copies
:loop
If [%1]==[] goto :copied
copy %1 c:\batch\copies
SHIFT
GOTO loop
:copied
>>c:\batch\copies\listing.txt dir /w c:\batch\copies
Type c:\batch\copies\listing.txt
If you are going to run this from a shortcut from within windows, you'll need to add a pause statement at the end to keep the window open. If you are running this from an open Command Prompt window, don't put an exit command at the end (or use exit /B as in dtech10's example)

Jerry
 
1 - 5 of 5 Posts
Status
Not open for further replies.
Top