GetSaveAsFilename with spaces in directory name - excel

I have a code which enables templates to be saved in a fixed directory with custom but suggested filenames. However, I also want to apply this to a different template in a directory whith a space in its name.
I read in a different question an answer about spaces making it more complex. (GetSaveAsFilename default folder) an answer:
this works:
x = Application.GetSaveAsFilename(InitialFileName:="C:\mydocuments\music\", _
fileFilter:="Text Files (*.*), *.*")
However, if you have spaces in the filespec it gets a little trickier. For example, this:
x = Application.GetSaveAsFilename(InitialFileName:="%USERPROFILE%\My Documents\My Music", _
fileFilter:="Text Files (*.*), *.*")
Only gets as far as My Documents and thinks that My Music is the filename. Hope this helps.)
So, what to do to have the right directory with a space in its name?

Enclose your path in quotes:
"""%USERPROFILE%\My Documents\My Music"""
to get spaces recognized as part of the path instead of separator.

Related

rename command for replacing text in filename from a certain point (character), but only up to, and maintaining the file extension

I've got a ton of files as follows
audiofile_drums_1-ktpcwybsh5c.wav
soundsample_drums_2-fghlkjy57sa.wav
noise_snippet_guitar_5-mxjtgqta3o1.wav
louder_flute_9-mdlsiqpfj6c.wav
I want to remove everything between and including the "-" and the .wav file extension, to be left with
audiofile_drums_1.wav
soundsample_drums_2.wav
noise_snippet_guitar_5.wav
louder_flute_9.wav
I've tried to do delete everything following and including the character "-" using
rename 's/-.*//' *
Which gives me
audiofile_drums_1
soundsample_drums_2
noise_snippet_guitar_5
louder_flute_9
And for lack of finding an easy way to rename all the files again, adding .wav the extension, I am hoping there is a slicker way to do this in one nifty command in one stage instead of 2.
Any suggestions?
Thanks
You can use rename 's/-[^\.]*\.wav$/\.wav/' *
The first part -[^\.]*\.wav$ searchs for a - followed by n chars that are not . followed by .wav and the end of filename. The end of filename and .wav is not strictly needed but it helps avoid renaming files you don't want to rename.
The /\.wav/ preserves the extension.
Please not that rename is not a standard utility, and is part of perl, so rename may not be available on every linux system.
This works in my specific case, but should work for any file extension.
rename -n 's/-.*(?=\.wav$)//' *
The command looks for all characters after and inclusive of the - symbol in the filename, then, using a positive lookahead** (?=\.wav$) to search for the characters (the file extension in this case) at the end of the filename (denoted by $, and replaces them with no characters (removing them).
** NOTE: A positive look ahead is a zero width assertion.
It will affect the match but it will not be included
in the replacement. (The '.wav' part will not be
erased)
In this example (?=\.wav$) is the positive lookahead. The dollar sign $, as in regex, denotes at the end of the line, so perfect for a file extension.

Deleting multiple files with special character in file name from perforce

I have a directory having 90K files. Lets call the directory as "dir". Many of the filenames has special
character like #, # etc.
I am looking for a command how can I mark all those files as deleted in perforce.
Thanks,
Pradip
Special characters are translated to %nn escape codes in the depot namespace, so to operate on those files you need to use the escape code instead of the original character. (The exception to this rule p4 add, which takes the original unescaped name and then escapes it as part of opening the file.)
To operate on all of the files that contain escape codes for # (%40) and # (%23) anywhere in their path relative to dir, use wildcards:
p4 delete dir/...%40...
p4 delete dir/...%23...

Linux script change file name,folder name and ingridents

I have a long folder/file structure with bunch of code files in it. some of my files has "x5g6" pattern on their name, on the folder name and also the text inside the files.
e.g
/Mycodes
/pp_x5g6
- vbg_x5g6.cmd
- x5g6_pp
- x5g6_pp.ml
so on so forth
also if you open vbg_x5g6.cmd file you can see there is a code in it and it also has this pattern (e.g function bb_x5g6 = x+ y);
My question is which commands I can use to recursively change x5g6 into x5g7
on folder, file names and also inside the files?
So far I could only found;
find . -type f -exec sed -i 's/x5g6/x5g7/g' {} +
but this only changes whatever inside the files not the folder and file names.
It looks like you have a solution already for editing the file contents.
For the file/directory names, I believe the generally accepted answers are to use either a program called mmv, (which I, myself, prefer), or one called rename
For the record, this question is a duplicate of https://unix.stackexchange.com/questions/98070/rename-files-in-directory.
The original there contains an answer also recommending zmv (if you're using zsh instead of bash).
edit: grammar

How i write file into home(In linux system)

I am trying to write file in my home folder(I am using Linux operating system) while i am writing the file into temp it's working
put shell("echo $HOME") into last1
The above code for getting home folder and I am place the path into variable last1
put the text of field "bash1" into URL "file:last1/dic.sh"
Here bash1 is an text field and it's contains some shell script i want to write into home directory
The below code is Works
put the text of field "bash1" into URL "file:/tmp/dic.sh"
How i rewrite my code
As your last1 variable is enclosed in quotes, it's getting treated as a literal string rather than a variable. The following would work:
put field "bash1" into URL ("file:" & last1 & "/dic.sh")
Note that you do not have to refer explicitly to the text property when putting texts from fields - you can do the above. Furthermore, if you're on Linux, you can just use the ~ shortcut to refer to the user's home directory:
put field "bash1" into URL "file:~/dic.sh"
You have to "open" the file, write your stuff and "close" the file again.
try something like
put last1 & "/dic.sh" into myFile
open file myFile for write
write the text of field "bash1" to file myFile
close file myFile

Search string in multiple files to write lines into one file

I'm relatively new in trying things out in the command prompt.
In the end I'd like to write a batch file that can do the following things.
Look for files whose name does not contain "foo" or "bar" with the extension "txt"
in the current directory, including all sub directories,
and search for lines starting with "create file" or "create table,"
so that all corresponding matching lines would be put into a new file named "y"
In the form of name of file in which the line was found, location of the file, and the actual line containing the string.
Start by looking at these commands.
Commands
for,
find,
findstr
Use the /? argument for help.
Batch References
SS64,
DosTips,
Rob van der Woude,
Technet

Resources