Skip to main content
replaced http://superuser.com/ with https://superuser.com/
Source Link

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(QuestionQuestion) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

Every problem solved final batch file :

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.doc" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns 
        ^| sort 
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

Every problem solved final batch file :

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.doc" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns 
        ^| sort 
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

Every problem solved final batch file :

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.doc" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns 
        ^| sort 
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)
Tweeted twitter.com/#!/super_user/status/587901551534088192
FINAL EDIT
Source Link
CodeIt
  • 1.8k
  • 1
  • 20
  • 28

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF
@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 
for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF
@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

Every problem solved final batch file :

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.doc" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns 
        ^| sort 
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

Every problem solved final batch file :

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.doc" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns 
        ^| sort 
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)
added 872 characters in body
Source Link
CodeIt
  • 1.8k
  • 1
  • 20
  • 28

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this .

I have got a plenty of .txt files in a directory. The directory also contains .png and some .pdf files. I have successfully concatenated .txt files using this command :

@ECHO Off
SETLOCAL
for /r %%f in (*.txt) do (
echo.
type "%%f"
)>> output.doc

GOTO :EOF

The above command was obtained from one of the online sites. This command will concatenate .txt files in alphabetical order. But i don't want it like that , i want it to be done by the date modified or created (modified is recommended). I have got a hint that the line

for /r %%f in(*.txt) do ( 

must be modified in order to concatenate by date.I'm new to this command line or batch scripting so i don't really know much about it. How should i do this . Thanks everyone for the answers.

Sorry for not including this question in the first time. I have got one more requirement based on another question that i asked previously(Question) i have got a batch file for concatenating .txt files and for adding two lines on top of every file (one for writing the file name without the extension and other for writing the date associated to the concatenated file).Can anyone please modify the below batch file to concatenate .txt files by the order of date-modified and to add the two lines on top of each file.

@echo off
SETLOCAL
for /r %%f in (*.txt) do (
echo File Name   : %%~nf 
FOR /f %%d IN ("%%~tf") DO echo Date        : %%d
echo.
type "%%f"
) >> output_text.doc

GOTO :EOF
edited tags
Link
CodeIt
  • 1.8k
  • 1
  • 20
  • 28
Loading
tag bash removed: no bash question/problem
Link
Loading
Source Link
CodeIt
  • 1.8k
  • 1
  • 20
  • 28
Loading