Tag Archive: batch


ls | Rename-Item -NewName {"1" + $_.name}
  • ls lists all files names in the current directory
  • | forwards the names to the Rename-Item command
  • -NewName renames the item to the name shown in the brackets
  • $_.name refers to the old name forwarded
  • „1“ + $_.name prepends 1 to the old name

copy the following lines to a bat file!

@echo off

:: Created by: Shawn Brink
:: http://www.tenforums.com
:: Tutorial: http://www.tenforums.com/tutorials/7923-folder-template-change-windows-10-a.html


REG ADD "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /V FolderType /T REG_SZ /D NotSpecified /F


:: To kill and restart explorer
taskkill /f /im explorer.exe
start explorer.exe

batch/bulk convert multiple tex files to PDF

The Tex distribution MikTex offers the command line program pdflatex to convert tex files to PDF. The program has often to be run twice to get page numbers correct.

An easy script on Windows 10 to do this might look like this:

for %%i in (%*) do (
pdflatex %%i
pdflatex %%i
)

The script needs pdflatex to be found on the PATH environment variable.
If you put the script in the Windows sendTo folder you can easily use it from a context menu.

If you edit files under Windows and then move them to a Linux server, you may encounter the problem that Windows uses \r\n as newline while Linux just uses \n. To remove the carriage return in all files ending on .sh or .SPEC use the following command:

 find . -type f \( -name "*.sh" -o -name "*.SPEC" \) -exec sh -c "tr -d '\15\32' {} > {}.nn" \; 

For each file found by find, a shell is executed, which again executes the tr command to drop \r. The tr command is given the current file via the {} parameter. The output of the tr command is redirected from the standard output to a new file that consists of the current file’s name ({} again} plus the ending .nn.