0

Is there a program (or a code for ReNamer or .cmd) that will copy the file readme.txt to every directory in the same directory as readme.txt is?

ReNamer: http://www.den4b.com/?x=products&product=renamer (there is a PascalScript rule, which let users program their very own renaming rule.)

I daily get over 50 new directories from work, they all need this file inside it. I've done over 1000 manually, I hope there is a solution for this.

Thanks!

Vikram
  • 3,996
  • 8
  • 37
  • 58
WHOMEZz
  • 79
  • 7

3 Answers3

0

Try this in a Batch script:

@echo off &setlocal
set "startdir=X:\start\folder"
for /d /r "%startdir%" %%i in (*.*) do copy readme.txt "%%~i"
endlocal
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • I made a copy.bat with your provided content, but it didnt work:`code` @echo off &setlocal set "startdir=C:\Work_VideoClasses" for /d /r "%startdir%" %%i in (*.*) do copy readme.txt "%%~i" endlocal`code` – WHOMEZz Mar 28 '13 at 14:19
  • check the output from this test code: `@echo off &setlocal` `set "startdir=C:\Work_VideoClasses"` `for /d /r "%startdir%" %%i in (*.*) do echo copy readme.txt "%%~i"` `endlocal` – Endoro Mar 28 '13 at 14:30
0
@echo off
FOR /R %%f in (.) DO xcopy readme.txt %%f

You save the .bat file in the same location as readme.txt, AND the subdirectries must be in the same folder as readme.txt: i.e

Desktop
    readme.txt 
    name.bat
    Sub1
    Sub2
    Sub3

etc....

Andriy M
  • 76,112
  • 17
  • 94
  • 154
CodeMonkey
  • 1,136
  • 16
  • 31
  • I made a copy.bat with your provided content, and did exactly what you said, but it didnt work:`code` @echo off FOR /R %%f in (.) DO xcopy readme.txt %%f`code` – WHOMEZz Mar 28 '13 at 14:21
0

Below is a PascalScript code for ReNamer which will create a Readme.txt file in every processed folder.

The script is executed during the preview, so for safety it will ask you whether to create Readme.txt or not every time you preview. This script uses ReadmeText constant for the content, but it could also be made that it copies the content of Readme.txt file from a file on your system. It will only create a Readme.txt file if one does not already exist. Drop all your folders into ReNamer and use this script.

const
  ReadmeName = 'Readme.txt';
  ReadmeText = 'Content of Readme file goes here!';
var
  Initialized: Boolean;
  ReadmePath: WideString;
  DoCreateReadmeFile: Boolean;
begin
  if not Initialized then
  begin
    Initialized := True;
    DoCreateReadmeFile := DialogYesNo('Create Readme file this time?');
  end;
  if WideDirectoryExists(FilePath) then
    ReadmePath := WideIncludeTrailingPathDelimiter(FilePath)
  else
    ReadmePath := WideExtractFilePath(FilePath);
  ReadmePath := ReadmePath + ReadmeName;
  if DoCreateReadmeFile and not WideFileExists(ReadmePath) then
    FileWriteContent(ReadmePath, ReadmeText);
end.

Edit

Script below will take a source file defined by SourceFilePath and copy it to the target folders. It will also warn you if source file does not exist.

const
  TargetFileName = 'Readme.txt';
  SourceFilePath = 'C:\Temp\Readme.txt';
var
  Initialized: Boolean;
  TargetFilePath: WideString;
  DoCreateFiles: Boolean;
begin
  if not Initialized then
  begin
    Initialized := True;
    if WideFileExists(SourceFilePath) then
      DoCreateFiles := WideDialogYesNo('Create "'+TargetFileName+'" files this time?')
    else
      WideShowMessage('Source file does not exist!'+#13#13+SourceFilePath);
  end;
  if WideDirectoryExists(FilePath) then
    TargetFilePath := WideIncludeTrailingPathDelimiter(FilePath)
  else
    TargetFilePath := WideExtractFilePath(FilePath);
  TargetFilePath := TargetFilePath + TargetFileName;
  if DoCreateFiles and not WideFileExists(TargetFilePath) then
    WideCopyFile(SourceFilePath, TargetFilePath, False);
end.
dezlov
  • 840
  • 8
  • 20
  • Thank you very much, but what about other files? f.e. an JPG - it would be really cool if you can give a path to a file, and copy this file to every dir you load up in ReNamer. – WHOMEZz Mar 28 '13 at 03:15
  • @WHOMEZz I have edited the post and added a script which will take a source file defined by `SourceFilePath` and copy it to the target folders. – dezlov Mar 28 '13 at 18:52