I faced a lot of issues with my mail exchange server quarantining my js files when i mail it my client. The way out of it was by renaming the .js file to .bak. But as the number of js files increased, it became a tedious process. So I thought of creating a bat file which could do two operations for me:
- Convert the .js files to .bak files
- Convert the .bak files to .js files
Here is the code you can use for these operations:
Convert .js to .bak (create_jstobak.bat):
@echo on
echo “This will convert all the .bak files to javascript(.js) files
rem Set CURRENTDIR=%CD%
rem ren “%CURRENTDIR%\javascript_files\*.bak” “*.js”
for /f “delims=” %%i in (‘dir /ad/s/b’) do ren “%%i\*.bak” “*.js”
pause
Convert .bak to .js (create_baktojs.bat):
@echo on
echo “This will convert all the javascript(.js) files to .bak files
rem Set CURRENTDIR=%CD%
rem ren “%CURRENTDIR%\javascript_files\*.js” “*.bak”
for /f “delims=” %%i in (‘dir /ad/s/b’) do ren “%%i\*.js” “*.bak”
pause
Remember:
- Correct the path given in the snippet above
- You can convert it to any other extension like .x or .y or .xyz instead of using bak
- Save the above text in a notepad file as a “.bat” file.
- Place the bat file in the appropriate location. Accordingly change the path mentioned in Line no. 4
Hope this helps!!