Batch code to process files with a certain filename in a directory

/ Published in: DOS Batch
Save to your folder(s)

This will loop through files in somefolder with the extension .c, print out the filename and compile the files.

Copy this code and paste it in your HTML
  1. @echo off
  2. cd %USERPROFILE%\Desktop\somefolder
  3. for %%f in (*.c) do (
  4. echo %%~nf
  5. gcc -c %%~nf.c -o %%~nf.o
  6. )

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.