How can I remove file name from path? (Makefile) - makefile

I want to convert "./folder/file.o" to "./folder".
How can I do this in make?

Figured it out. You need to use ($dir ./folder/file).
File-Name-Functions

Related

Is it possible to use scp and change a filename to $date

So I have this script that creates a file called "myfile.txt" this name will never change.
I have 2 servers srv01 and srv02
srv01:/home/user/scriptdata/myfile.txt is the file I want to move to srv02
I want this file to arrive at srv02 in the following format
srv02:/home/user/scriptoutput/$date.txt
Is there an easy way to do this?
So far I have been using scp /home/user/scriptdata/myfile.txt 12.34.56.78:/home/user/scriptoutput/day-month-year.txt manually
scp /home/user/scriptdata/myfile.txt 12.34.56.78:/home/user/scriptoutput/data_$(date +%d-%m-%Y_%H:%M).txt
This worked! thanks jhnc for ur answer

Using Ruby to find a file with changing directory

I'm trying to find a file in which the directory will change its name with upcoming versions, so an example could be that it is located under /opt/here/test-1.44/bin/progname and will follow the format same time.
I'm looking to do something like if File.exist?("/opt/here/test-*/bin/progname") but is that the correct format? When searching around I'm also seeing references to using Dir, so would it be something like if Dir['/opt/here/*'.select { |f| f =~ /progname/} then ?
Thanks!
Do
Dir.glob("/opt/here/test-*/bin/progname").empty?
Use any? instead of empty? if you want true when there is such file.

Check if a file exists using a wildcard

In Ruby, how can I check if a file exists using a wildcard?
Apparently this does not seem to work:
File.exists?("/folderOfFile/Filename*.ext")
Your wildcard would refer to a set of files, not a single file. You could use Dir::glob for this:
!Dir.glob('/folderOfFile/Filename*.ext').empty?

Dealing with ini Files - Add Enivornment Variable

i am trying to add an evironment variable to a path inside an ini file, the variable is the current username in Windows which can be accessed via %username%.
so i would like to do path = c:\users\[username variable]\ ...
Will appreciate anyhelp
Use ExpandEnvironmentStrings().
See WritePrivateProfileString() and friends...

How do I get the directory where the executable is located?

I got the filename like this:
_TCHAR filename[_MAX_PATH];
GetModuleFileName(NULL,filename,sizeof(filename));
How do I remove the filename from this full path? Should I use regex?
You can use the Windows shell API function PathRemoveFileSpec to do this. Example usage is listed on the linked page.
Since you use VS++, you can use:
_splitpath and _wsplitpath functions to break apart path

Resources