I want to copy files from temporary folder to in my c drive by creating new folder - inno-setup

if FileCopy(ExpandConstant('{tmp}\SPECTRUMJOBS_Data.MDF'),
ExpandConstant('C:\Program Files\Microsoft SQL Server\MSSQL11.LOGISTICS\MSSQL\DATA\SPECTRUMJOBS_Data.MDF'),
False) then
I tried the above one but I am not able to copy because there is no folder named DATA in the location.
so please help me to copy the DATA folder and the file

To force creation of directories you can use (text is from InnoSetup help):
Prototype:
function ForceDirectories(Dir: string): Boolean;
Description:
Creates all the directories along the specified directory
path all at once. If the first directories in the path do exist, but
the latter ones don't, ForceDirectories creates just the ones that
don't exist. Returns True if successful, False otherwise.
InnoSetup documentation is at ishelp

You answered yourself. If there is no folder DATA in folder MSSQL, the folder must be created first.
And... if there is no folder MSSQL in folder MSSQL11.LOGISTICS, that folder must be created first.
And so on...
Now read the above sentences in reverse order, and you're done.

Related

Node : What is the right way to delete all the files from a directory?

So I was trying to delete all my files inside a folder using node.
I came across 2 methods .
Method 1
Delete the folder using rmkdir. But if I plan on adding the images on the same folder then I use mkdir and creates the same folder again and appends the files to it.
Example: I have an Add Files and Delete ALL button. When I click deleteAll , the folder gets deleted. And when I click add then the folder gets created and the file gets added to that folder
Method 2
Using readdir , I loop through the files and stores in an array and then delete only the files instead of the folder.
Which is the best way to do it ? If its not among these then please advice me a better solution.
The rm function of ShellJS will do the trick. It works as a one-liner, and it works cross-platform, and is well tested and documented. It even supports recursive deletes.
Basically, something such as:
const { rm } = require('shelljs');
rm('-rf', '/tmp/*');
(Sample code taken from ShellJS' documentation.)

Deleting a file IF any folders in current directory contain a keyword using batch

I am trying to write a batch file that takes a backup using temporary folders and a "sub-batch" file that needs to be deleted once all backups are completed.
The method I'm trying to use copies a batch file to the main directory, opens multiple instances of this batch which create "temp" folders, then they remove the temp folder once they are done their business.
I want to implement a command at the end of the sub-batch that checks if any folders with the word "temp" exist in the directory, then delete the sub-batch if none exist.
I have tried many iterations, but this is what I kind of ended at before asking this question:
rd %TempFolder% /S /Q
cd C:\BackupDirectory
if exist C:\BackupDirectory\*_Temp_*\ goto :unconnect
del subBatch.bat
:unconnect
I realize that this won't work, but I can't find a good way to find the string "temp" in the sub-directory name.
Any help is appreciated.

Node js. Writing directory to the archive, without path to this directory

Got some task, it is not hard, but i have some trouble.
Maybe someone already has similar problem.
My task is writing to zip archive some folder, with files and other folders in it with using NodeJS
I try to use AdmZip pakage
folder project structure:
var AdmZip = require('adm-zip');
let Archive = new AdmZip();
Archive.addLocalFolder('Archive/filesFolder', '');
Archive.writeZip('Archive/newArchive.zip);
I must get archive with 'filesFolder', instead i get archive with 'Archive' folder and in it i have 'filesFolder'.
If anybody know, how to record only target folder, and not the sequence of a way folders?
What happens is that you are providing Archive/filesFolder as value to writeZip and that means include in the zip Archive folder and inside that include filesFolder.
For testing purpose change the value of writeZip() to just filesFolder.zip and it should zip content of Archive as filesFolder.zip in current working directory. See below (you can copy/paste the bit of code and run it and it should work).
var zip = new AdmZip();
// I don't know why you provided a second argument to below, I removed it
// There was nothing about it in the documentation.
zip.addLocalFolder('./Archive');
//rename the value of the following to just filesFolder.zip
zip.writeZip('filesFolder.zip');
The above should output the content of Archive to the current working directory as filesFolder.zip
I did mention this in my comment and your commend seem to indicate that you have path issue, so try the above script.

Move directory using C#

I'm trying to cut a folder. I've tried directoy.move(string source,string dest) & directoryinfo.moveto(dest) but in both case an exception was thrown "Source and destination path must have identical roots. Move will not work across volume".
You cannot move files and folders across different volumes with Directory.Move. You have to create the directory at the destination, recursively copy the files across then, on success, delete the files at the source or, as Tim suggested in the comments below, recursively create the directory structure then move the files across with File.Move.

Qt Installer framework - Copying files to location other than install directory

I know that, whatever data is placed in package/component dir/data, will be copied to the install directory. What I mean is if I have a binary, readme, license.txt inside package/component dir/data/myapp, package/component dir/data/readme, package/component dir/data/license.txt and if I choose my target installation dir to be “/opt/myfirstapp”, then inisde /opt/myfirstapp, I will have 3 files copied, myapp, readme, license.txt.
Having said that, I also have a “/usr” directory with in package/component dir/data/, however this is not the standard “/usr” which will be inside root “/”, it is just a replica. Now inside my replica “/usr” I have some directory hierarchy and some files, like /usr/bin/myapp, /usr/lib/libmyapp.so, /usr/share/icons” and many more, infact a lot. Now I want the replica “/usr” content to be copied to “/usr” (the original usr inside root folder). I should also make sure that I just add new contents to “/usr” (root /usr), but delete any existing content.
Question is clear, some files inside my data directory will have to go to target install dir, but some selected ones (for ex: /usr) will have to be copied to other paths. How do I achieve this.
Currently we have the same problem in my company: we need 2 target directories, one for the exe and one for the libraries (well, it's a bit more complex but in few words...).
After having spoken with Qt support and got the answer that it's actually not possible ("It is possible only after extracting. After extraction, you can use copy or move operation, unfortunately there is currently no other way.") I decided to use the AdminTargetDir as the second target directory. This because there's no other way to pass dynamic variables to the IFW. So after installation I call a "finalizeInstall_patch.bat" file passing the TargetDir and AdminTargetDir and this will move the libraries directory from TargetDir to AdminTargetDir. Why a .bat patch file ? because it's actually not possible to move a directory using the methods provided by the IFW. Qt support just opened a suggestion-ticket for our problem: https://bugreports.qt-project.org/browse/QTIFW-595
I hope that this answer will help others having same similar problems.
NOTE: There is a way to move a directory (on Windows), calling addOperation("Execute", "cmd /C move source dest...") but this brings to other problems out of topic here.
This worked for us (Qt Installer, macOS):
var args = ["cp", "-R", "#TargetDir#/MyApp.app", "/Applications"];
component.addOperation("Execute", args);

Resources