-2
for %%s in (Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\TTFILE*.*) do (
 Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\deasn9.exe -a      Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\cme20MSS13a_itu -b  %%s   >Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\tmp\%%s:~ns.txt
)

i tried to get filenames from folder Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\

but \%%s:~ns cannot get filename ,why?

foxidrive
  • 40,353
  • 10
  • 53
  • 68
kasson
  • 45
  • 1
  • 1
  • 5
  • Use `dir`, that's how you get filenames in dos. – sashoalm Jan 10 '14 at 09:15
  • i want get the filenames in script as var. – kasson Jan 10 '14 at 09:37
  • Well, my friend, you should learn to write better titles. Now edit your **question's title** and make it clear what you want. – sashoalm Jan 10 '14 at 09:42
  • possible duplicate of [batch scripting iterating over files in a directory](http://stackoverflow.com/questions/138497/batch-scripting-iterating-over-files-in-a-directory) – sashoalm Jan 10 '14 at 11:25
  • Pure dos is MSDOS which doesn't support foldernames or filenames over 8.3 characters. Your example shows that you are using Windows CMD. – foxidrive Jan 12 '14 at 09:10

2 Answers2

0
set "dataFiles=Y:\ACS\data\rtr\CHS_cp0ex\dataFiles"

for %%s in ("%dataFiles%\Reported\TTFILE*.*") do (
    "%dataFiles%\Reported\deasn9.exe" -a "%dataFiles%\Reported\cme20MSS13a_itu" -b "%%~fs" >"%dataFiles%\tmp\%%~ns.txt"
)

There was a lot of paths. I've replaced them with a variable, but this is not needed.

Now, the references to files in the for command variable

%%s will hold a reference to the file. Full path, relative or no path to the file will or will not be included depending on how the set of files is indicated in the for command

%%~ns The name, without extension, of the file

%%~nxs The name, with extension, of the file

%%~fs The full path to the file. Drive, folders, filename and extension.

For a full list of the different modifiers, see for /?

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Y:\>("Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\deasn9.exe" -a "Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\cme20MSS13a_itu" -b "Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\TTFILE.201401101630282600" 1>"Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\tmp\TTFILE.txt" ) The system cannot execute the specified program. Y:\>("Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\deasn9.exe" -a "Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\cme20MSS13a_itu" -b "Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\Reported\TTFILE.201401101630422601" 1>"Y:\ACS\data\rtr\CHS_cp0ex\dataFiles\tmp\TTFILE.txt" ) – kasson Jan 10 '14 at 10:08
  • why all filenames is TTFILE.txt – kasson Jan 10 '14 at 10:09
  • i also use %%~nxs the same an belows – kasson Jan 10 '14 at 10:11
  • @user3143869: `The system cannot execute ...` Path to the executable is translated from your code. If it is not there, adapt as needed. – MC ND Jan 10 '14 at 10:21
  • @user3143869: `all filenames are TTFILE.txt` : Well, from your output, all files are named `TTFILE`, the only difference is in the extension, so, in `"%dataFiles%\tmp\%%~ns.txt"` change `%%~ns.txt` to `%%~nxs.txt` – MC ND Jan 10 '14 at 10:25
  • i find it that the reason of it cannot run is that i run it in Pure DOS. but i thank you very much. – kasson Jan 12 '14 at 02:30
-2

Dir is what you are looking for. You sound like a unix user.

Programmer
  • 6,565
  • 25
  • 78
  • 125