Renaming all files and folders in directory with ROT13 using batch file - batch-rename

First time poster, apologies if my formatting is incorrect.
I recently stumbled upon this batch script that uses JREPL:
#echo off
For /R %%G IN (.) DO (
pushd %1 .
call :sub
popd
exit /b
:sub Subroutine needed to guarantee %-f0 gives the correct value
setlocal
set "find=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
set "repl=NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
set "p=/(.*)/"
set "prepl={$1}"
for /f "delims=" %%C in (
'cmd /c "for %%F in (*) do #if "%%~fF" neq "%~f0" echo ren "%%F" "/%%~nF/%%~xF""^|jrepl find repl /t "" /p p /prepl "{$1}" /v'
) do echo %%C&%%C
)
And it works great for encrypting the names of files but I want it to do the folders and sub-folders as well. This is because I want to obfuscate the names of my files for privacy reasons when uploading them onto a cloud for remote access.
I have tried several backup/encryption utilities that offer filename encryption but they cannot be opened unless you use the same utility, and I need other devices without access to the utility to be able to open them.

Related

CMake "Could not read from count file."

In my main CMakeLists file I include() another cmake file which has these two lines:
add_custom_target(myTarget)
add_custom_command(TARGET myTarget COMMAND echo ARGS "Here is an echo" WORKING_DIRECTORY ${PARENT_DIR})
Here is the output after I build and run 'make myTarget':
Could not read from count file.
Here is an echo
Built target myTarget
Could not read from count file.
I have no idea what this 'count file' is that it tells me about twice. Can anyone tell me what this means?
Cmake version 3.6.2
The "count file" is where CMake logs the build progress, so that it can give its "% complete" output.
I seriously doubt the "could not read from count file" is related to your two lines. Insufficient write permissions to the binary directory, perhaps, or some path mismatch?
I had the same problem (in a build directory where I had accidentally called cmake from a sub directory). Removing all contents of the build directory and running cmake again fixed the issue.

DLL project : migrating from Qt + MinGW to Visual Studio

I'm making a DLL, written in C++ with Qt Creator (but no Qt stuff inside, pure homemade C++), and using a standard qmake + MinGW/g++ build process. My friend is doing the framework/main soft, and he's using Visual Studio Express 2015, and he's supposed to use my DLL inside of that. Because of that I want to use the same visual studio compiler for my project in Qt Creator.
So I noticed that Qt Creator had auto detected the Visual Studio C++ 14 compiler, which I believe is the one attached to Visual Studio Express 2015. When I create a kit with that compiler and set my project to compile with that kit, I get a suggested "Make" step which calls jom in the bin folder of my Qt Creator installation. I have no idea what this is and I get the following output (see below).
I don't know what to do from here. I also tried to create a compiler directly from the nmake executable in my Visual Studio installation, and then using it - but I get a very similar error about '-' not being recognized as an option. Any hints are greatly appreciated !
12:56:27: Starting: "C:\Qt\qtcreator-3.1.1\bin\jom.exe"
Usage: jom #commandfile
jom [options] [/f makefile] [macro definitions] [targets]
nmake compatible options:
/A build all targets
/D display build information
/E override environment variable macros
/F <filename> use the specified makefile
/G display included makefiles
/H show help
/I ignore all exit codes
/K keep going - build unrelated targets on error
/N dry run - just print commands
/NOLOGO do not print logo
/P print makefile info
/R ignore predefined rules and macros
/S silent mode
/U print content of inline files
/L same as /NOLOGO
/W print the working directory before and after other processing
/X <filename> write stderr to file.
/Y disable batch mode inference rules
jom only options:
/DUMPGRAPH show the generated dependency graph
/DUMPGRAPHDOT dump dependency graph in dot format
/J <n> use up to n processes in parallel
/KEEPTEMPFILES keep all temporary files
/VERSION print version and exit
Error: unknown command line option '-' in arguments: '/L-j4'
12:56:27: The process "C:\Qt\qtcreator-3.1.1\bin\jom.exe" exited with code 128.
Error while building/deploying project Ford_DAT_framework_DLL_as_plugin (kit: MVS Ford)
When executing step 'Make'
12:56:27: Elapsed time: 00:04.
So I used qmake -tpvc to generate a VCproj file which compiled almost immediately in Visual Studio Express 2015 which my friend uses. I guess that's a valid solution to my problem then !

How to know whether the cmake project generation ended with success

The last few weeks I'm playing with build automation. With the help of Cmake, I'm able to generate Visual Studio solution and MinGW makefile for Windows and also GCC makefile for Linux. The Cmake task is executed through a batch file on Windows respectively through a shell script on Linux. Everything looks correct and works as expected. My plan is to setup different test servers where the whole build and test process will be automated and the results will be reported somewhere.
One thing I was not able to figure out yet is how to obtain the result of the cmake command. I would like to know whether the cmake command ended successfully or not, so in case of error the fail will be reported. At this moment I'm able to parse the result and look for "Build files have been written to: ..." sentence, but I think it is not really robust solution.
Is there a way to determine whether the cmake command was successful or not? I don't want to stick necessarily to batch files, Python (or other) scripts are also welcome. Thanks.
Just make sure your scripts do exit with the error levels reported by the programs you're calling.
Let me explain this with showing an example:
vs2015_x86_build.cmd
#ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
:: usage:
:: vs2015_x86_build.cmd <target> <config>
:: <target> - target to be built (default: ALL_BUILD)
:: <config> - configuration to be used for build (default: Debug)
if NOT "%1" == "" (SET CMAKE_TARGET=%1) else (SET CMAKE_TARGET=ALL_BUILD)
if NOT "%2" == "" (set CMAKE_BUILD_TYPE=%2) else (set CMAKE_BUILD_TYPE=Debug)
SET CMAKE_BINARY_DIR=vs2015_x86
IF NOT EXIST "%CMAKE_BINARY_DIR%\*.sln" (
cmake -H"." -B"%CMAKE_BINARY_DIR%" -G"Visual Studio 14 2015"
SET GENERATE_ERRORLEVEL=!ERRORLEVEL!
IF NOT "!GENERATE_ERRORLEVEL!"=="0" (
DEL /F /Q "%CMAKE_BINARY_DIR%\*.sln"
EXIT /B !GENERATE_ERRORLEVEL!
)
)
cmake --build "%CMAKE_BINARY_DIR%" --target "%CMAKE_TARGET%" --config "%CMAKE_BUILD_TYPE%"
SET BUILD_ERRORLEVEL=!ERRORLEVEL!
IF NOT "!BUILD_ERRORLEVEL!"=="0" (
EXIT /B !BUILD_ERRORLEVEL!
)
ENDLOCAL
References
Does CMake always generate configurations for all possible project configurations?
Have an additional action associated with the ultimate target, like the creation of a file, or the appending of a time-stamped log entry to a given file.

CMake/CPack command for InstallDirRegKey

In an NSIS script file, it is possible to set the following, to use a registry entry as the install directory:
InstallDirRegKey HKCU "Software\Test" "RegEntry"
I was wondering if it would be possible to set this command from a cmake file, so that the NSIS script is automatically generated. Much in the same way the directory of an install can be set like:
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "testDir")
Many thanks
I'm not following exactly what you're trying to do, but if you just want a custom command in the NSIS file, you can do this:
list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
InstallDirRegKey HKCU \"Software\\Test\" \"RegEntry\"
")
Be careful of the backslashes, needed to escape the double quote and the literal backslash. I think you might need 4 backslashes instead of 2 for the literal backslash, but try it and see. Check the resulting NSIS file, and add more backslashes as necessary.
EDIT:
There's another, much more complete way to customize the NSIS install script. According to this: http://cmake.org/Wiki/CMake:CPackNSISAdvancedTips you can copy NSIS.template.in (from your CMake installation) into your source tree (in a directory that's on your CMAKE_MODULE_PATH) and modify it.
list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
InstallDirRegKey HKCU \"Software\\Test\" \"RegEntry\"
")
translates on my machine to
InstallDirRegKey HKCU ;Software\Test" "RegEntry;`
Try rather
list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
InstallDirRegKey HKCU 'Software\\\\Test' 'RegEntry'
")

Avoid quoting in CMake add_custom_command

I'm trying to create a simple batcher, which runs a script over a set of files.
So, after globbed files, I've created the following custom command to execute the script:
add_custom_command(OUTPUT ${RESOURCE_GFX} COMMAND ${EXE_GFX_EXPORT} ${GFX_EXPORT_PARAMETERS} ${RESOURCE_SWF})
where EXE_GFX_EXPORT is the script program, something like C:\Program Files (x86)\Scaleform\GFx SDK 3.1\Bin\gfxexport.exe; RESOURCE_SWF is the file that the script runs on; and GFX_EXPORT_PARAMETERS are script's parameters, something in the form of -i DDS -share_images -qp.
CMake "translates" this custom command in:
"C:\Program Files (x86)\Scaleform\GFx SDK 3.1\Bin\gfxexport.exe" "-i DDS -share_images -qp" "C:\path\to\file.swf"
but gfxexport.exe can't handle parameters surrounded by double quotes. Is there a way to avoid CMake automatically puts them around GFX_EXPORT_PARAMETERS variable?
Thanks guys,
Raffaele.
Try using the separate_arguments function on the parameter GFX_EXPORT_PARAMETERS before invoking add_custom_command:
separate_arguments(GFX_EXPORT_PARAMETERS_LIST WINDOWS_COMMAND "${GFX_EXPORT_PARAMETERS}")
add_custom_command(OUTPUT ${RESOURCE_GFX} COMMAND ${EXE_GFX_EXPORT} ${GFX_EXPORT_PARAMETERS_LIST} ${RESOURCE_SWF})