Windows File Sharing: Add/Remove folders via Command Line

Filed Under (Hacks, Tutorials) by Karun on 04-07-2010

Tagged Under : , , ,

Your first thought on reading this probably is “Why in the world would I need to do that?” Well, I would have thought of it the same way a week back. But it seems some times, Windows does not want to give access to certain features such as Advanced File Sharing options. It states that the administrator on my machine has disallowed this operation. Guess what? I’m the only administrator on this machine! Since I was unable to find the option to get that feature working, I decided to resort to some good old Command Line usage :)

To remove a file/folder from share and type the following command in an elevated instance of command prompt:

net share <shareName> /delete

To add a file/folder to share and type the following command in an elevated instance of command prompt:

net share <shareName>=<pathToSharedFile>

An example of an add and delete command would be as follows

net share “Completed Downloads”=”D:\Completed Downloads”
net share “Completed Downloads” /delete

At times, I was not required to use an elevated command prompt instance but if you get message stating “Access Denied”, you should run the command after elevation. To do so, type out “Command Prompt” in your start menu and then use the right click > Run as administrator option or you could simply use Shift+Enter to do the same :)

Simple enough, right? ;)

Torrenting on Linux

Filed Under (Tutorials) by Karun on 21-02-2010

Tagged Under : , , , , ,

rutorrent webUI

rutorrent webUI screenshot (traffic statistics)

As of today, the primary OS on my laptop is Ubuntu and since torrenting is a good way to get open source applications (such as Eclipse), I thought I should definitely invest the time to get a decent torrent client. I’m not saying that Transmission isn’t a good client. I certainly can’t say that since I haven’t used it for more than 5 minutes. I simply lacks umph. It really doesn’t impress me as much as uTorrent does on Windows. So let’s look for an alternative client.

Using uTorrent with Wine is always a popular option, one most Windows to Linux converts happily embrace. Let’s face it, uTorrent is awesome. But I really wanted to embrace Linux which for me meant to stop using the mouse and GUI as much as possible (not that difficult for me) and getting used to native applications rather than applications via Wine. This meant no more uTorrent for torrenting and no more mIRC :( The alternative I settled for came highly recommended by quite a few users. And oh, look at that, it’s terminal based. Of course, I’m talking about rTorrent ;)

I have tried to install rTorrent before and failed. This time around, I had managed to get rTorrent to install and work fine but I couldn’t get a webUI for it to work. So I had dt walk me through the process. I’ll try to document as much of it as possible to help users going through the same issue.

If you want to see a couple of screen shots of the end result before beginning, visit the rutorrent website and check out the screen shots. The best part about it is the tracker based, per torrent and global settings along with the pretty amazing traffic plug-in which gives your multiple (group) views of your traffic statistics. It’s pretty cool ;)

Read the rest of this entry »

Playing videos in RAR archives

Filed Under (Tutorials) by Karun on 07-12-2009

Tagged Under : , , , ,

A lot of people today download videos (TV shows and movies) off the internet using torrents or Usenet. Most sources pack the videos in multi-part RAR archives to minimize loss in case of error prone transfer. Though this does not make much sense usually on protocols such as the bittorrent protocol but it does on the scene where data is transferred using FTP. In such cases, you are left with a lot of rar files that you have to keep (if you’re seeding on trackers) and extract every time you want to play them.

Some video players like VLC and XBMC came up with a solution. On the fly extraction of multi-part archives to play videos. Not all players support this though. Just recently, I came across something that can solve this problem. You can now use RARFileSource to get your favourite video player to read videos in RAR files and play them.  RARFileSource is a DirectShow filter which let’s most video players read RAR files on the fly. The only restriction is that the video should not be compressed. Thankfully, this is the scene norm so you need not worry. Just install the application (117 KB) and drag drop a RAR archive on to your favourite video player. Works fine with MPC: HC for me and WMP for dt (who suggested this to me).

Now you can seed your files and play them from the RAR archives directly only extracting them when you need to give them to someone else ;) Cool, eh? :D

Clean File List Generation with PowerShell Script

Filed Under (Development, Tutorials) by Karun on 06-12-2009

Tagged Under : , ,

I have a whole load of movies that I’d like to generate a list of. I considered writing a batch script but it didn’t really do something I needed. I ended up writing my first regular use (non test) PowerScript and here’s how.

My first requirement was to list all my 1080p movies and for the list to leave out all the subtitles. So I was looking for a function to list files (dir in command prompt did that :)) and then remove files by extension. As it turned out, I could list files of a certain extension but not leave out files by extensions. Finally, I had to write the result to file (simple enough to do in command prompt. Use the > operator to direct output of the previous command to a file) So, a quick fix would be to use something like

dir *.avi *.mp4 *.mpg *.mpeg *.mkv /B /O N

For sub-folders, you can use tree and fiddle around the options but lets face it, as programmers, we want better solutions.

Since the launch of Windows 7, Microsoft has shipped PowerShell with the OS making it much more “main stream”. I had played around with PowerShell a couple of years ago when version 1 came out but I thought it was time that I actually made a regular use script.

The core of the script is using get-childitem to get all files and folders in a directory. From there, you can make it go recursive (and look inside sub directories) with a -recurse switch. Little bit of piping allows you to eliminate results you don’t need. For this, I wrote a simple function.

function fileCheck([string]$extention, [string]$attributes) {
# list of rejected extentions
$exts = “.srt”,”.sub”,”.idx”,”.txt”,”.lnk”

return $exts -notcontains $extention -and $attributes -ne “Directory”
}

As you’ve probably figured out, this function ignores those file extensions and directories as well from our final file list.

Once you have the list, you can either use $object.Name for full name (ie file name with extension) or $object.BareName for only the file name. On reading the source of my script, you’ll see I’m using both and also writing a count of the number of files in a file named list.txt. The first part of the file is a human readable list for your consumption using new lines for separation. The second is a single line output of all files using commas for separation and containing a file count at the end. The latter is simply for copy pasting into chats (like IRC) where you can’t spam with a huge multi-line list.

I went on then to add more code to handle command line inputs so that you can make shortcuts from folders and call the script. I have attached a couple of sample script calls

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command& ‘C:\Users\Karun\My Scripts\filelist.ps1‘” “H:\Movies\HQ
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command& ‘C:\Users\Karun\My Scripts\filelist.ps1‘” “H:\Movies” “true

The first one will call on the script and generate an output. The second will do so recursively. Simple enough? Go get the code and have fun with it!

View Script Source Code | Download Script Source Code

If you’re having trouble executing the script, you should consider signing your PowerShell scripts. Scott Hanselman has written a great post on how to do so. Go read it! You could simply Set-ExecutionPolicy to Unrestricted but then you’d be leaving your system open to attacks. Don’t blame anyone but yourself if you run someone else’s unsafe code and screw something up :) You have been warned :)

Building a Home Server: Part 1

Filed Under (Hacks, Tutorials) by Karun on 10-09-2009

Tagged Under : , , , , ,

The first question in your head would be “Why the world do I need a Home Server?

Good question. I’d like to ask you a couple of things. Do you have multiple machines in your house? Do you ever feel like you should have centralized storage in your house? Do you have old hardware simply lying around the house waiting to be tinkered with? Do you like playing with your machines?

If you said yes to (most) of the above questions, having a Home Server could help you :) It can handle not only centralized storage of media and documents but also backups. Have you ever needed a file from computer x in your house and found it was shut down after being used by a family member? Well, you wouldn’t have this issue if you had a central server. People could go around switching off their machines all they want as long as you have the file you want on your Storage Server.

Lets get into it then. From now, I’ll walk you through how to make your old machine into a Network Attached Server (NAS).

Read the rest of this entry »