How execute file from parent directory without changing directories - windows

I'm an enthusiast of efficiency. I want to execute a file in a parent directory and would appreciate it if anyone knows of a slick way to do it.
I'm using Windows command line.
lets say i have a file: C:\Documents\text.txt
and my current directory is: C:\Documents\pycode
I would like to open the textfile without changing directories or writing entire filepath.
I tried "..\text.txt" but it doesn't work.

Just add quotes.
"../text.txt"
Or, you can try this:
notepad "../text.txt"

Related

Shell script to copy and paste a particular file from one directory to another?

As part of a Windows software project I'm working on I need to copy and paste a particular DLL file from directory A to directory B. In the process, I need to overwrite any previous version of this file in directory B.
Directory A is: Documents/Visual Studio/2015/Project/MyProject/MyProject/bin/Debug
Directory B is: This PC/Windows(C:)/Users/Public/Public Documents/B
Is there a shell script that can perform this operation?
Any help would be greatly appreciated!
Described goal can be achieved by single cmd command:
copy /Y "%USERPROFILE%\Documents\Visual Studio\2015\Project\MyProject\MyProject\bin\Debug\libName.dll" "C:\Users\Public\Public Documents\B"
So you can put this command into scriptName.bat file and execute. Put pause at the end of the file to prevent window closing if you want to check script output.

OS X bash For loop only processes one file in a directory

I'm trying to get this code to process all files in a directory : https://github.com/kieranjol/ifi-ffv1/blob/master/ifi-ffv1.sh
I run it in the terminal and add path to file ./ifi-ffv1.sh /path/to/file.mov. How can I get it to move on to the next? I'll also need to make sure that it only processes AV files, such as .avi/.mkv/*.mov etc.
I've tried using while loops with shift but I can't get that to work either.
I've tried adding a specific path like here but I'm failing http://www.cyberciti.biz/faq/unix-loop-through-files-in-a-directory/
I've tried this https://askubuntu.com/a/315338 and it keeps looping the same file rather than moving on to the next one. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html this didn't help me either.
I know this is going to be a horribly simple solution but I'm very new to this.
You don't actually have any kind of loop in your code. You need to do something like
for file in path/to/*.avi path/to/*.avg
do
./ifi-ffv1.sh "$file"
done
which will loop through all the specified files and substitute each one for $1
You can put whatever file names you want instead of the path/to/*.avi path/to/*.avg. If you cd to the directory first, you can leave out the paths, and just use *.avi *.avg
To do it all in one script, do something like this:
cd <your directory>
for file in *.avi *.avg
do
<your existing script here>
done
replacing all the $1's in your script with "$file" (not duplicating any quotes you already have, of course)

Deleting a directory without looking inside

I have a directory in my hard drive which causes a bug that opening this directory opens itself again and again in a loop. And this goes on until computer freezes. I have tried with several program and couldn't remove it. Is there a command line command that removes directory without ever looking inside it so, i can get rid of this file.
I am looking for any solution than formatting my hard drive, doesn't have to be command
Thank you
Write a C++ code using this library
https://msdn.microsoft.com/en-US/library/67y3z33c(v=vs.80).aspx
and edit that directory with the code

Deleting a File or Replacing a File when Outsheeting in Stata

I open up a .txt file. Make some modifications to it. Then I'd like to outsheet it with the same name. To do this, I presume either I'd have to delete the file right before I outsheet it or replace the file in the outsheeting process. As a backup, I can manually delete the .txt execute the relevant code.
I'd like to do this via Stata, however. Is it possible to either:
1. Delete a .txt file within a Stata .doe--say with a shell command ?
2. Overwrite a .txt file in the outsheeting process ?
I am outsheeting as in:
outsheet v1 v2 using "file.txt", nolabel delim(",")
I run Stata in Windows on an XP machine.
Add the replace option anywhere after the comma.
You can can also shell out to the OS. Type "h shell" to see how.
Or just use rm/erase directly.

How can I gain permission to rename a file for my Ruby program?

As per the answer to this question, I am trying to backup a file by renaming it, before I replace it with a new, modified file with the old name.
As per the comments and the documentation here, I am using the following line of code:
File.rename(File.basename(modRaw), File.basename(modRaw)+'.bak')
However, when I do so, I get the following error at runtime:
The program then aborts. (leatherReplacer.rb is the name of my program, and line 88 is the above line of code)
How do I allow my program to rename the files it needs to to run successfully?
Windows has some special rules regarding permissions. The important one at work here, is that the OS prevents moving or renaming a file while the file is open.
Depending on the nature of your code (in size and scope) and the importance of the file you're trying to back up, it may be unfeasible or otherwise not worthwhile to refactor the code in such a way as to make backups possible.
You probably don't want to be calling File.basename in there, that strips off the directory:
Returns the last component of the filename given in *file_name*, which must be formed using forward slashes ("/") regardless of the separator used on the local file system.
So, if modRaw is /where/is/pancakes.house, then you're saying:
File.rename('pancakes.house', 'pancakes.house.bak')
But pancakes.house probably isn't in the script's current directory. Try without the File.basename calls:
File.rename(modRaw, modRaw + '.bak')
If you are owner of that file, use File.chmod to set desired permissions.
I don't know much about ruby, but could you run it under command line/bash with admin privileges, such as "run as administrator" or "su root"?
According to Objectmix and ruby-forum, you should set it to 755 or +x, then perhaps chown to yourself.
try using full file path e.t
File.rename('c:\pancakes.house', 'c:\pancakes.house.bak')
in win7 i encounter same problem

Resources