Correct command to copy a directory list into a text file

G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Subject: We have a problem with a copy diretory command that has worked fine in eariler Windows versions.

Specifications:

Copy the file names in one directory to a text file in another directory using a system call.
We do not want to copy the directory itself.

We just want the file names to be listed in a destination text file.

We don't care if the directory path of each file is copied into the text file.
Either the file names OR the file name with path as a list will be fine.

What should be the command format to copy a directory list into a file in Windows 2000?

We have been using a system call to execute the following command.

This DOS cmd.exe command has been successful on windows XP and earlier windows versions when called by from an
application software program:

C:\WINDOWS\system32.cmd.exe /c dir /b c:\inputfilesdir\ > c:\filedirectories\directorytoday.txt

1. c:\inputfilesdir\ contains 1 to many files and file types.

2. The above dos command is called from an application software program

3. After the above command is called in windows xp, the directory.txt file contains the directory listing of
all files in c:\inputfilesdir\

4. c:\filedirectories\directorytoday.txt is the destination file that contains a simple, sequential list of the file names after the command is executed.

Our problem:
--The command is not working in Windows 2000.
--The command has worked fine in prior Windows versions.

Specifications:
1. Copy the file names in a directory to a text file using a system call.

2. After the list of files is in the text file, each wil be opened and processed by an application.
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

PROMETRIC <pshr1996@yahoo.com> wrote:

>C:\WINDOWS\system32.cmd.exe

Is this a typo?

Best regards

Bjorn
--
Bjorn Landemoo - mvp2@landemoo.com - http://landemoo.com/
Microsoft MVP - Windows Server Networking
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Here is the actual log with my notes indicated by =====>

=====>Application receives a parameter (directory path to be processed) and displays the parameter it received:
$Filename = G:\Psft841\Files\sun2jde\input
P1: G: P2: Psft841 P3: Files P4: sun2jde P5: input P6:
$RC_Directory = G:\Psft841\Files\sun2jde\input
Processing all files in directory specified on run panel G:\Psft841\Files\sun2jde\inputAll results will be placed in this same directory

get-in-file-names-and-process

=====>Test the change directory command returns a 0 status
$ChgDirCall: C:\WINNT\SYSTEM32\CMD.EXE cd /D g:
0.000000

=====>Test the change directory command returns a 0 status
$ChgDirCall: C:\WINNT\SYSTEM32\CMD.EXE cd /D G:\Psft841\Files\sun2jde\input0.000000

=====>A text file name is determined based on the parameter received by the application:
Filelist: G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT

=====>A copy directory command is generated as follows and it returns a 0 return code:
Copy directory command follows:
C:\WINNT\SYSTEM32\CMD.EXE /C dir /b G:\Psft841\Files\sun2jde\input\ > G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT
Copy directory status: 0.000000

=====>The application attempts to open the text file that should contain file names and it fails with a return of -1.0000
Process-File-From-Files-List
Open file: G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT Status: -1.000000

=====>Due to the non zero return code on the attempt to open the file, the application ends processing.

Review of results:
1. G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT does exist on the Windows 2000 server.

2. When looking at the contents of file SUN2JDEFILESLIST.TXT the file is empty, even though the copy directory command was successful and the source directory contained a multitude of files (file names). Those file names should have ended up in SUN2JDEFILESLIST.TXT

3. In earlier versions of Windows, such as NT, Windows 95, Windows XP, we have no problem and use this type of command for several applications.

4. It appears something is wrong with this copy directory command for Windows 2000:

C:\WINNT\SYSTEM32\CMD.EXE /C dir /b G:\Psft841\Files\sun2jde\input\ > G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT

The total length of the above command is 132 characters. In the above paste, it rolled into 2 lines.

Thanks much!
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Yes. That was a typo it shold have been the path on the server:
C:\WINNT\SYSTEM32\CMD.EXE

Again, thanks much!
 

overlord

Distinguished
Aug 29, 2001
120
0
18,680
Archived from groups: microsoft.public.win2000.file_system (More info?)

On Tue, 11 May 2004 14:21:04 -0700, =?Utf-8?B?UFJPTUVUUklD?= <anonymous@discussions.microsoft.com>
wrote:

>Here is the actual log with my notes indicated by =====>
>
>=====>Application receives a parameter (directory path to be processed) and displays the parameter it received:
>$Filename = G:\Psft841\Files\sun2jde\input
> P1: G: P2: Psft841 P3: Files P4: sun2jde P5: input P6:
>$RC_Directory = G:\Psft841\Files\sun2jde\input
>Processing all files in directory specified on run panel G:\Psft841\Files\sun2jde\inputAll results will be placed in this same directory
>
>get-in-file-names-and-process
>
>=====>Test the change directory command returns a 0 status
>$ChgDirCall: C:\WINNT\SYSTEM32\CMD.EXE cd /D g:
>0.000000
>
>=====>Test the change directory command returns a 0 status
>$ChgDirCall: C:\WINNT\SYSTEM32\CMD.EXE cd /D G:\Psft841\Files\sun2jde\input0.000000
>
>=====>A text file name is determined based on the parameter received by the application:
> Filelist: G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT
>
>=====>A copy directory command is generated as follows and it returns a 0 return code:
>Copy directory command follows:
>C:\WINNT\SYSTEM32\CMD.EXE /C dir /b G:\Psft841\Files\sun2jde\input\ > G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT
> Copy directory status: 0.000000
>
>=====>The application attempts to open the text file that should contain file names and it fails with a return of -1.0000
> Process-File-From-Files-List
> Open file: G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT Status: -1.000000
>
>=====>Due to the non zero return code on the attempt to open the file, the application ends processing.
>
>Review of results:
>1. G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT does exist on the Windows 2000 server.
>
>2. When looking at the contents of file SUN2JDEFILESLIST.TXT the file is empty, even though the copy directory command was successful and the source directory contained a multitude of files (file names). Those file names should have ended up in SUN2JDEFILESLIST.TXT
>
>3. In earlier versions of Windows, such as NT, Windows 95, Windows XP, we have no problem and use this type of command for several applications.
>
>4. It appears something is wrong with this copy directory command for Windows 2000:
>
>C:\WINNT\SYSTEM32\CMD.EXE /C dir /b G:\Psft841\Files\sun2jde\input\ > G:\Psft841\Files\sun2jde\Filesprocessed\SUN2JDEFILESLIST.TXT
>
I don't see anything wrong with the command....
Can you break it down at the prompt?

CMD
verify on
g:
cd \
cd Psft841\Files\sun2jde\input
dir > sun2jdefineslistTEST.txt
dir sun2jdefineslistTEST.txt
type sun2jdefileslistTEST.txt
move /y sun2jdefineslistTEST.txt G:\Psft841\Files\sun2jde\Filesprocessed\

===What are the files attributes?
attrib | more

===If the files are hidden, they won't show up on the dir /d

===just a thought.....

>The total length of the above command is 132 characters. In the above paste, it rolled into 2 lines.
>
>Thanks much!
~~~~~~
Bait for spammers:
root@localhost
postmaster@localhost
admin@localhost
abuse@localhost
postmaster@[127.0.0.1]
uce@ftc.gov
~~~~~~
Remove "spamless" to email me.
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Thanks for your review.
I will definitely update you when we get it working.

Again, thanks.
Ken